当前位置:网站首页>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;
}
边栏推荐
- Developing desktop applications with electron
- Solon Auth 认证框架使用演示(更简单的认证框架)
- Introduction to memory layout of FVP and Juno platforms
- TF-A中的工具介绍
- Control Unit 控制部件
- [turn]: OSGi specification in simple terms
- 数仓项目的集群脚本
- Summary of Haut OJ 2021 freshman week
- A misunderstanding about the console window
- [turn to] MySQL operation practice (I): Keywords & functions
猜你喜欢

Gbase database helps the development of digital finance in the Bay Area
![[to be continued] [UE4 notes] L2 interface introduction](/img/0f/268c852b691bd7459785537f201a41.jpg)
[to be continued] [UE4 notes] L2 interface introduction
![[trans]: spécification osgi](/img/54/d73a8d3e375dfe430c2eca39617b9c.png)
[trans]: spécification osgi
![[merge array] 88 merge two ordered arrays](/img/e9/a73d9f22eead8e68c1e45c27ff6e6c.jpg)
[merge array] 88 merge two ordered arrays
![To be continued] [UE4 notes] L4 object editing](/img/0f/cfe788f07423222f9eed90f4cece7d.jpg)
To be continued] [UE4 notes] L4 object editing

Light a light with stm32

A new micro ORM open source framework

对象的序列化

Pointnet++学习

Yolov5 adds attention mechanism
随机推荐
How can the Solon framework easily obtain the response time of each request?
Chapter 6 data flow modeling - after class exercises
[trans]: spécification osgi
用STM32点个灯
To the distance we have been looking for -- film review of "flying house journey"
PMP candidates, please check the precautions for PMP examination in July
[turn]: OSGi specification in simple terms
[binary search] 69 Square root of X
Haut OJ 1218: maximum continuous sub segment sum
搭建完数据库和网站后.打开app测试时候显示服务器正在维护.
第六章 数据流建模—课后习题
剑指 Offer 53 - II. 0~n-1中缺失的数字
服务熔断 Hystrix
[interval problem] 435 Non overlapping interval
剑指 Offer 06.从头到尾打印链表
【Jailhouse 文章】Look Mum, no VM Exits
A new micro ORM open source framework
挂起等待锁 vs 自旋锁(两者的使用场合)
sync.Mutex源码解读
Software test -- 0 sequence