結果
問題 | No.584 赤、緑、青の色塗り |
ユーザー |
![]() |
提出日時 | 2025-02-04 04:12:02 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,452 bytes |
コンパイル時間 | 741 ms |
コンパイル使用メモリ | 82,420 KB |
実行使用メモリ | 111,248 KB |
最終ジャッジ日時 | 2025-02-04 04:12:11 |
合計ジャッジ時間 | 8,055 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 13 TLE * 1 |
ソースコード
N,R,G,B=map(int,input().split())mod=10**9+7FACT=[1]for i in range(1,2*10**5+1):FACT.append(FACT[-1]*i%mod)FACT_INV=[pow(FACT[-1],mod-2,mod)]for i in range(2*10**5,0,-1):FACT_INV.append(FACT_INV[-1]*i%mod)FACT_INV.reverse()def Combi(a,b):if 0<=b<=a:return FACT[a]*FACT_INV[b]%mod*FACT_INV[a-b]%modelse:return 0ANS=0for x in range(min(R,G),-1,-1):for y in range(min(G,B),-1,-1):for z in range(min(B,R),-1,-1):if x*2+y*2+z*2>N:breakRrest=R-x-zGrest=G-x-yBrest=B-y-z#print(x,y,z,Rrest,Grest,Brest)if Rrest<0 or Grest<0 or Brest<0:continueneed = x+y+z+Rrest+Grest+Brest-1#print(x,y,z,Rrest,Grest,Brest,need)if x*2+y*2+z*2+Rrest+Grest+Brest+need>N:breakempty=N-x*2-y*2-z*2-Rrest-Grest-Brest-need#print("!",x,y,z,Rrest,Grest,Brest,need,empty)AX=Combi(x+y+z+Rrest+Grest+Brest,x)*Combi(y+z+Rrest+Grest+Brest,y)*Combi(z+Rrest+Grest+Brest,z)*Combi(Rrest+Grest+Brest,Rrest)*Combi(Grest+Brest,Grest)%modAY=pow(2,x+y+z)%modAZ=Combi(empty+(x+y+z+Rrest+Grest+Brest),empty)#print("!?",x,y,z,Rrest,Grest,Brest,need,empty,AX,AY,AZ,AX*AY*AZ%mod)ANS=(ANS+AX*AY*AZ)%modprint(ANS%mod)