当前位置:网站首页>CCPC Weihai 2021m eight hundred and ten thousand nine hundred and seventy-five
CCPC Weihai 2021m eight hundred and ten thousand nine hundred and seventy-five
2022-07-05 05:31:00 【solemntee】
The question
the n n n game , win victory m m m game , One of the longest winning streak is k k k, Ask how many situations .
Answer key
consider a n s k ans_k ansk by : the n n n game , win victory m m m game , One of the longest winning streak Greater than or equal to k k k, Ask how many situations .
Because there is n − m n-m n−m Negative fields , So consider the surrounding of each negative field as empty Then insert the victory .
enumeration i i i The continuous length is greater than or equal to k k k Wins , Enumerate the locations of these consecutive wins empty , The number is ( i n − m + 1 ) (^{n-m+1}_{\ \ \ \ \ \ i}) ( in−m+1), Then the next arbitrary allocation can , The number of options is ( n − m n − i k ) (^{n-ik}_{n-m}) (n−mn−ik), so
a n s k = ∑ i = 1 m − i ∗ k > = 0 ( − 1 ) i + 1 ( i n − m + 1 ) ( n − m n − i k ) ans_k=\sum_{i=1}^{m-i*k>=0}(-1)^{i+1}(^{n-m+1}_{\ \ \ \ \ \ i})(^{n-ik}_{n-m}) ansk=i=1∑m−i∗k>=0(−1)i+1( in−m+1)(n−mn−ik)
The final output a n s k + 1 − a n s k ans_{k+1}-ans_k ansk+1−ansk that will do
Special , If you consider generating functions , Enumerate each empty The number of winning fields inside can be made by polynomial fast power , The maximum win is less than or equal to k k k The number of schemes can be determined by
a n s k = ( 1 + x 2 + . . + x k ) n − m + 1 = ( 1 − x k + 1 1 − x ) n − m + 1 ans_k=(1+x^2+..+x^k)^{n-m+1}= (\frac {1-x^k+1} {1-x} )^{n-m+1} ansk=(1+x2+..+xk)n−m+1=(1−x1−xk+1)n−m+1
The number of times is m Expressed by the term coefficient of , Then the answer is a n s k − a n s k − 1 ans_k-ans_{k-1} ansk−ansk−1
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=998244353;
ll poww(ll a,ll b)
{
ll t=1;
while(b)
{
if(b&1)t=t*a%mod;
a=a*a%mod;
b>>=1;
}
return t;
}
ll P1[300005],P2[300005];
void init()
{
P1[0]=P2[0]=1;
for(int i=1;i<=300000;i++)P1[i]=P1[i-1]*i%mod;
P2[300000]=poww(P1[300000],mod-2);
for(int i=299999;i>=1;i--)P2[i]=P2[i+1]*(i+1)%mod;
}
ll C(ll n,ll m)
{
return P1[n]*P2[m]%mod*P2[n-m]%mod;
}
int main()
{
init();
long long n,m,k;
scanf("%lld%lld%lld",&n,&m,&k);
ll ans=0;
if(k==0)
{
printf("%d\n",m==0);
return 0;
}
for(ll i=1;i*k<=m;i++)
{
if(i&1)ans=(ans+C(n-m+1,i)*C(n-i*k,n-m)%mod)%mod;
else ans=(ans-C(n-m+1,i)*C(n-i*k,n-m)%mod)%mod;
// printf("ans=%lld\n",ans);
}
k++;
for(ll i=1;i*k<=m;i++)
{
if(i&1)ans=(ans-C(n-m+1,i)*C(n-i*k,n-m)%mod)%mod;
else ans=(ans+C(n-m+1,i)*C(n-i*k,n-m)%mod)%mod;
}
printf("%lld",(ans%mod+mod)%mod);
return 0;
}
I don't know why I'm so stupid B B B The title of the game will be stuck ?
边栏推荐
- Pointnet++的改进
- SAP-修改系统表数据的方法
- [es practice] use the native realm security mode on es
- Haut OJ 1316: sister choice buys candy III
- 剑指 Offer 09. 用两个栈实现队列
- YOLOv5-Shufflenetv2
- Pointnet++ learning
- [to be continued] [UE4 notes] L3 import resources and project migration
- Sword finger offer 04 Search in two-dimensional array
- Add level control and logger level control of Solon logging plug-in
猜你喜欢
Corridor and bridge distribution (csp-s-2021-t1) popular problem solution
Fragment addition failed error lookup
Binary search basis
个人开发的渗透测试工具Satania v1.2更新
挂起等待锁 vs 自旋锁(两者的使用场合)
[speed pointer] 142 circular linked list II
剑指 Offer 53 - II. 0~n-1中缺失的数字
Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
[turn to] MySQL operation practice (I): Keywords & functions
随机推荐
Codeforces Round #715 (Div. 2) D. Binary Literature
第六章 数据流建模—课后习题
个人开发的渗透测试工具Satania v1.2更新
Zzulioj 1673: b: clever characters???
Romance of programmers on Valentine's Day
[binary search] 34 Find the first and last positions of elements in a sorted array
SDEI初探-透过事务看本质
服务熔断 Hystrix
kubeadm系列-02-kubelet的配置和启动
Demonstration of using Solon auth authentication framework (simpler authentication framework)
[to be continued] [UE4 notes] L2 interface introduction
Haut OJ 1241: League activities of class XXX
[speed pointer] 142 circular linked list II
Pointnet++学习
每日一题-搜索二维矩阵ps二维数组的查找
Mysql database (I)
Add level control and logger level control of Solon logging plug-in
[turn to] MySQL operation practice (III): table connection
剑指 Offer 09. 用两个栈实现队列
Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade