結果
問題 |
No.269 見栄っ張りの募金活動
|
ユーザー |
![]() |
提出日時 | 2019-08-26 12:32:33 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 4,867 ms / 5,000 ms |
コード長 | 447 bytes |
コンパイル時間 | 326 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 331,984 KB |
最終ジャッジ日時 | 2024-11-07 18:56:34 |
合計ジャッジ時間 | 12,927 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
import sys from collections import defaultdict sys.setrecursionlimit(1000000) n,s,k=map(int,input().split()) res=s-k*n*(n-1)//2 MOD=10**9+7 if res<0: print(0) sys.exit() dic=defaultdict(int) def rec(a,b): if a<0: return 0 if dic[(a,b)]!=0: return dic[(a,b)] if a==0 or b==1: dic[(a,b)]=1 return 1 x=rec(a,b-1) y=rec(a-b,b) z=(x+y)%MOD dic[(a,b)]=z return z print(rec(res,n))