标签:cti ctime long class etc ++ else ... scan
传送门
题目大意
现在有n个k面的骰子,问在i=2~2*k的情况下,任意两个骰子向上那一面的和不等于i的方案数是多少。
分析
代码
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<cctype> #include<cmath> #include<cstdlib> #include<queue> #include<ctime> #include<vector> #include<set> #include<map> #include<stack> using namespace std; const long long mod = 998244353; long long c[4100][4100],pw[4100],vis[4100]; inline void getc(){ long long i,j; for(i=0;i<=4000;i++) c[i][0]=c[i][i]=1; for(i=1;i<=4000;i++) for(j=1;j<i;j++) c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod; return; } inline void getpw(){ pw[0]=1; for(long long i=1;i<=4000;i++)pw[i]=pw[i-1]*2%mod; return; } inline long long work(long long i,long long n,long long k){ long long k1,k2,Ans=0,wh=-1,j; k2=min(k-i/2,(i-1)/2); k1=k-k2*2-(i+1)%2; for(j=0;j<=k2;j++){ wh*=-1; Ans=(Ans+wh*c[n+k1+k2-j-1][k1+k2-j-1]*pw[k2-j]%mod*c[k2][k2-j]%mod +mod)%mod; } return Ans; } int main(){ long long n,k,i; scanf("%lld%lld",&k,&n); getc(); getpw(); for(i=2;i<=2*k;i++){ if(i&1){ printf("%lld\n",work(i,n,k)); }else printf("%lld\n",(work(i,n,k)+work(i,n-1,k))%mod); } return 0; }
标签:cti ctime long class etc ++ else ... scan
原文地址:https://www.cnblogs.com/yzxverygood/p/9696188.html