結果

問題 No.269 見栄っ張りの募金活動
ユーザー rpy3cpprpy3cpp
提出日時 2015-08-21 23:37:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 5,000 ms
コード長 331 bytes
コンパイル時間 1,521 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 75,700 KB
最終ジャッジ日時 2023-09-23 01:05:32
合計ジャッジ時間 4,600 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,064 KB
testcase_01 AC 72 ms
71,228 KB
testcase_02 AC 73 ms
71,248 KB
testcase_03 AC 77 ms
75,376 KB
testcase_04 AC 87 ms
75,700 KB
testcase_05 AC 75 ms
75,432 KB
testcase_06 AC 70 ms
71,220 KB
testcase_07 AC 107 ms
75,552 KB
testcase_08 AC 70 ms
71,216 KB
testcase_09 AC 72 ms
71,092 KB
testcase_10 AC 70 ms
71,060 KB
testcase_11 AC 77 ms
75,588 KB
testcase_12 AC 71 ms
71,240 KB
testcase_13 AC 77 ms
75,388 KB
testcase_14 AC 72 ms
75,272 KB
testcase_15 AC 77 ms
75,440 KB
testcase_16 AC 71 ms
71,292 KB
testcase_17 AC 70 ms
71,396 KB
testcase_18 AC 83 ms
75,400 KB
testcase_19 AC 77 ms
75,496 KB
testcase_20 AC 74 ms
75,476 KB
testcase_21 AC 74 ms
75,436 KB
testcase_22 AC 77 ms
75,400 KB
testcase_23 AC 74 ms
75,268 KB
testcase_24 AC 75 ms
75,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(N, S):
    mod = 10**9 + 7
    if S < 0: return 0
    elif S == 0: return 1
    dp = [1] * (S + 1)
    for n in range(2, N):
        for s in range(n, S + 1):
            dp[s] = (dp[s - n] + dp[s]) % mod
    return sum(dp[S::-N]) % mod    

N, S, K = map(int, input().split())
S -= N * (N-1) * K // 2
print(solve(N, S))
0