結果

問題 No.269 見栄っ張りの募金活動
ユーザー 藤原正貴藤原正貴
提出日時 2020-05-26 18:12:23
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 532 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 275,328 KB
最終ジャッジ日時 2024-04-21 04:24:33
合計ジャッジ時間 3,258 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 37 ms
52,224 KB
testcase_02 RE -
testcase_03 AC 64 ms
68,096 KB
testcase_04 AC 190 ms
132,096 KB
testcase_05 AC 43 ms
58,032 KB
testcase_06 AC 37 ms
51,840 KB
testcase_07 AC 555 ms
275,328 KB
testcase_08 AC 38 ms
51,672 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 68 ms
69,632 KB
testcase_12 RE -
testcase_13 AC 90 ms
83,072 KB
testcase_14 AC 45 ms
59,008 KB
testcase_15 AC 87 ms
83,200 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 177 ms
121,984 KB
testcase_19 AC 88 ms
83,200 KB
testcase_20 AC 45 ms
59,008 KB
testcase_21 AC 46 ms
59,008 KB
testcase_22 AC 70 ms
73,984 KB
testcase_23 AC 49 ms
60,800 KB
testcase_24 AC 44 ms
59,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,S,K = map(int,input().split())
S -= (K+(N-1)*K)*(N-1)//2
mod = 10**9 +7
if S == 0:
    print(1)
elif S < 0:
    print(0)
else:
    #dp[i][j]->i人でjを値の組み合わせの重複なしで分割するパターン数
    dp = [[0]*(S+1) for _ in range(N+1)]
    for i in range(N+1):
        dp[i][0]=1
    for j in range(S+1):
        dp[1][j] = 1
    for i in range(2,N+1):
        for j in range(1,S+1):
            dp[i][j] += dp[i-1][j]
            if j-i>=0:
                dp[i][j] += dp[i][j-i]

print(dp[-1][-1]%mod)

0