Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
37102 | 22级廖思学 | 【S】T4 | C++ | 通过 | 100 | 515 MS | 469008 KB | 1368 | 2025-03-02 21:25:54 |
#include<bits/stdc++.h> using namespace std; #define int long long const int N=2e7+10,M=998244353; int id,n,r,g,b,ans; int fac[N],inv[N],pw[N]; int Pow(int a,int b){ if(a==0)return 1; int ans=1; while(b>0){ if(b&1)ans=ans*a%M; a=a*a%M;b>>=1; }return ans; } signed main(){ fac[0]=1;for(int i=1;i<=N-5;i++){fac[i]=fac[i-1]*i%M;} inv[N-5]=Pow(fac[N-5],M-2); for(int i=N-6;i>=0;i--){inv[i]=inv[i+1]*(i+1)%M;} pw[0]=1;for(int i=1;i<=N-5;i++){pw[i]=pw[i-1]*2%M;} scanf("%lld",&id); scanf("%lld%lld%lld",&r,&g,&b);n=r+g+b; int c=g-b; for(int x=r-1;x<=r+1;x++){//枚举r隔出了多少个空 for(int i=((x+c)%2+2)%2;i<=x;i+=2){//x-x0与c mod2 同余 int j=(c+x-i)/2,k=(x-i-c)/2,res=0; if(j<0||k<0)continue; res=fac[x]*inv[i]%M*inv[j]%M*inv[k]%M; int now=g-i-j; if(now<0)continue; if(now>0)res=res*fac[x+now-1]%M*inv[x-1]%M*inv[now]%M; res=res*pw[i]%M;if(x==r)res=res*2%M; // cout<<x<<" "<<i<<" "<<j<<" "<<k<<" "<<res<<endl; // cout<<fac[x]*Pow(i,M-2)%M*Pow(j,M-2)%M*Pow(k,M-2)%M<<" "<<Pow(2,i)<<" "<<now<<" "<<fac[x+now-1]%M*Pow(fac[x-1],M-2)%M*Pow(fac[now],M-2)%M<<endl; ans=(ans+res)%M; } } printf("%lld\n",ans); return 0; }