2018 Multi-University Training Contest 8
Posted hetui
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2018 Multi-University Training Contest 8相关的知识,希望对你有一定的参考价值。
1001:
公式题,可以用容斥和隔板法推出来。
#include <iostream> #include <cstdio> #include <cstdlib> using namespace std; const int MAX=3e5+5; const long long mod=998244353; long long fac[MAX],rev[MAX]; long long qp(long long p,long long q) { int cnt=1; while(q>0) { if(q%2==1) cnt=(cnt*p)%mod; q/=2; p=(p*p)%mod; } return cnt%mod; } long long C(long long a,long long b) { if(a<0||b<0) return 0; long long flag=fac[a]; return ((fac[a]*rev[b])%mod*rev[a-b])%mod; } long long n,m,k; long long solve(long long sum,long long num,long long p) { if(sum==0) return 1; long long cnt=0; int i,j; for(i=0;i<=num;i++) { long long a=C(num,i),b=C(sum-p*i-i+num-1,sum-p*i-i); long long flag=(C(num,i)*C(sum-p*i-i+num-1,sum-p*i-i))%mod; if(i%2==1) flag=(mod-flag)%mod; cnt=(cnt+flag)%mod; } return cnt; } int main() { int i,j; int t; scanf("%d",&t); fac[0]=1; rev[0]=1; for(i=1;i<MAX;i++) { fac[i]=(fac[i-1]*i)%mod; rev[i]=qp(fac[i],mod-2); } while(t--){ scanf("%lld%lld%lld",&n,&m,&k); long long ans=solve(k,m,n-1); printf("%lld ",ans); } return 0; }
1002:
1004:
1005:
1010:
1011:
1012:
以上是关于2018 Multi-University Training Contest 8的主要内容,如果未能解决你的问题,请参考以下文章
2018 Multi-University Training Contest 2
2018 Multi-University Training Contest 9
2018 Multi-University Training Contest 4
2018 Multi-University Training Contest 4