提交时间:2025-03-02 21:17:22
运行 ID: 37101
#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]; 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; 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]*Pow(fac[i],M-2)%M*Pow(fac[j],M-2)%M*Pow(fac[k],M-2)%M; int now=g-i-j; if(now<0)continue; if(now>0)res=res*fac[x+now-1]%M*Pow(fac[x-1],M-2)%M*Pow(fac[now],M-2)%M; res=res*Pow(2,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; }