結果

問題 No.269 見栄っ張りの募金活動
ユーザー crow_vanishcrow_vanish
提出日時 2019-08-26 12:20:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 418 bytes
コンパイル時間 120 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 38,768 KB
最終ジャッジ日時 2024-04-25 08:30:03
合計ジャッジ時間 4,354 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,624 KB
testcase_01 AC 32 ms
10,752 KB
testcase_02 AC 35 ms
10,752 KB
testcase_03 AC 68 ms
12,672 KB
testcase_04 AC 741 ms
38,768 KB
testcase_05 AC 33 ms
10,880 KB
testcase_06 AC 31 ms
10,752 KB
testcase_07 RE -
testcase_08 AC 31 ms
10,752 KB
testcase_09 AC 34 ms
10,624 KB
testcase_10 AC 31 ms
10,624 KB
testcase_11 AC 163 ms
17,276 KB
testcase_12 AC 34 ms
10,752 KB
testcase_13 AC 231 ms
19,928 KB
testcase_14 RE -
testcase_15 AC 214 ms
19,088 KB
testcase_16 AC 33 ms
10,624 KB
testcase_17 AC 33 ms
10,752 KB
testcase_18 AC 687 ms
37,352 KB
testcase_19 AC 199 ms
18,516 KB
testcase_20 AC 58 ms
12,468 KB
testcase_21 AC 60 ms
14,196 KB
testcase_22 AC 133 ms
15,828 KB
testcase_23 AC 40 ms
11,136 KB
testcase_24 AC 78 ms
13,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10000)
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()
dp=[[-1]*(n+1) for i in range(res+1)]
def rec(a,b):
    if a<0:
        return 0
    if dp[a][b]!=-1:
        return dp[a][b]
    if a==0 or b==1:
        dp[a][b]=1
        return 1
    x=rec(a,b-1)
    y=rec(a-b,b)
    z=(x+y)%MOD
    dp[a][b]=z
    return z
print(rec(res,n))
0