結果

問題 No.269 見栄っ張りの募金活動
ユーザー tktk_snsntktk_snsn
提出日時 2020-06-02 16:44:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,095 ms / 5,000 ms
コード長 417 bytes
コンパイル時間 857 ms
コンパイル使用メモリ 10,892 KB
実行使用メモリ 86,224 KB
最終ジャッジ日時 2023-08-15 18:43:19
合計ジャッジ時間 5,018 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,024 KB
testcase_01 AC 15 ms
7,820 KB
testcase_02 AC 15 ms
8,116 KB
testcase_03 AC 45 ms
10,476 KB
testcase_04 AC 382 ms
35,408 KB
testcase_05 AC 17 ms
7,832 KB
testcase_06 AC 15 ms
7,820 KB
testcase_07 AC 1,095 ms
86,224 KB
testcase_08 AC 16 ms
7,788 KB
testcase_09 AC 15 ms
8,104 KB
testcase_10 AC 15 ms
7,836 KB
testcase_11 AC 96 ms
13,928 KB
testcase_12 AC 16 ms
8,232 KB
testcase_13 AC 136 ms
16,848 KB
testcase_14 AC 36 ms
9,004 KB
testcase_15 AC 123 ms
15,956 KB
testcase_16 AC 15 ms
8,100 KB
testcase_17 AC 15 ms
8,096 KB
testcase_18 AC 372 ms
34,724 KB
testcase_19 AC 126 ms
15,816 KB
testcase_20 AC 36 ms
9,440 KB
testcase_21 AC 39 ms
9,592 KB
testcase_22 AC 84 ms
13,060 KB
testcase_23 AC 24 ms
8,716 KB
testcase_24 AC 50 ms
10,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, S, K = map(int, input().split())
mod = 10 ** 9 + 7

base = sum(i * K for i in range(N))
if base > S:
    print(0)
    exit()
S -= base


# dp[i][j]  jをi分割
dp = [[0] * (S + 1) for _ in range(N + 1)]
dp[0][0] = 1
for i in range(1, N + 1):
    for j in range(S + 1):
        if j >= i:
            dp[i][j] = (dp[i - 1][j] + dp[i][j - i]) % mod
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[N][S])
0