当前位置:网站首页>Codeforces Round #732 (Div. 2) D. AquaMoon and Chess
Codeforces Round #732 (Div. 2) D. AquaMoon and Chess
2022-07-05 05:30:00 【solemntee】
First, let's consider the simpler case
1100000000000 1100000000000 1100000000000
hold 11 11 11 As a group , This group can move on the number axis , The situation of each group corresponds to one s t a t e state state
Extension , For a continuous string of odd length
000011111000000 000011111000000 000011111000000
You can know that there is l e n / 2 len/2 len/2 A mass of , When the number of the left and right groups of this continuous string is determined, this group leaves “1” The location is uniquely determined , Take the example above , You can know that if the two regiments are on the left, what remains is the rightmost 1 1 1, One on the left and one on the right are left in the middle 1 1 1……
Back to the topic , We find all the cliques in a string , Then the conclusion drawn from the above , When the position of the regiment is determined, it is left alone “1” Determine the location , So we only need to consider the position relationship of the Group .
The problem turns into 1 ∗ m 1*m 1∗m Space for n n n individual 1 ∗ 2 1*2 1∗2 Number of options for items . Just write a formula .
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=998244353;
ll poww(ll a,ll b)
{
ll t=1;
while(b>1)
{
if(b%2==1)t=t*a%mod;
a=a*a%mod;
b/=2;
}
return t*a%mod;
}
ll poww1[100005],poww2[100005];
void init()
{
poww1[0]=1;
poww2[0]=1;
for(int i=1;i<=100000;i++)poww1[i]=poww1[i-1]*i%mod;
for(int i=1;i<=100000;i++)poww2[i]=poww2[i-1]*poww(i,mod-2)%mod;
// printf("%lld\n",poww2[3]);
}
char s[100005];
int main()
{
init();
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
scanf("%s",s+1);
int cnt0=0,cnt=0,cnt2=0;
for(int i=1;i<=n;i++)
{
if(s[i]=='0')cnt0++;
if(s[i]=='1')cnt++;
if(s[i]=='0')
{
cnt2+=cnt/2;
cnt=0;
}
}
cnt2+=cnt/2;
printf("%lld\n",poww1[cnt0+cnt2]*poww2[cnt0]%mod*poww2[cnt2]%mod);
}
return 0;
}
边栏推荐
- Talking about JVM (frequent interview)
- 质量体系建设之路的分分合合
- Haut OJ 1245: large factorial of CDs --- high precision factorial
- Under the national teacher qualification certificate in the first half of 2022
- Software test -- 0 sequence
- Haut OJ 1401: praise energy
- Control Unit 控制部件
- MySQL数据库(一)
- 第六章 数据流建模—课后习题
- Solon Auth 认证框架使用演示(更简单的认证框架)
猜你喜欢

Web APIs DOM node

Gbase database helps the development of digital finance in the Bay Area
![[speed pointer] 142 circular linked list II](/img/f8/222a360c01d8ef120b61bdd2025044.jpg)
[speed pointer] 142 circular linked list II

Corridor and bridge distribution (csp-s-2021-t1) popular problem solution

lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8

lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8

服务熔断 Hystrix

Sword finger offer 58 - ii Rotate string left

sync.Mutex源码解读

Sword finger offer 05 Replace spaces
随机推荐
剑指 Offer 53 - I. 在排序数组中查找数字 I
Alu logic operation unit
过拟合与正则化
[binary search] 34 Find the first and last positions of elements in a sorted array
[allocation problem] 135 Distribute candy
Haut OJ 1241: League activities of class XXX
Sword finger offer 04 Search in two-dimensional array
MySQL数据库(一)
A preliminary study of sdei - see the essence through transactions
[turn]: OSGi specification in simple terms
[depth first search] 695 Maximum area of the island
[to be continued] [UE4 notes] L3 import resources and project migration
The number of enclaves
剑指 Offer 53 - II. 0~n-1中缺失的数字
kubeadm系列-02-kubelet的配置和启动
Romance of programmers on Valentine's Day
Daily question - longest substring without repeated characters
National teacher qualification examination in the first half of 2022
Haut OJ 1357: lunch question (I) -- high precision multiplication
利用HashMap实现简单缓存