結果

問題 No.269 見栄っ張りの募金活動
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-09-10 22:13:03
言語 Python2
(2.7.18)
結果
AC  
実行時間 518 ms / 5,000 ms
コード長 442 bytes
コンパイル時間 56 ms
コンパイル使用メモリ 6,704 KB
実行使用メモリ 141,240 KB
最終ジャッジ日時 2023-09-23 01:12:56
合計ジャッジ時間 2,398 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,044 KB
testcase_01 AC 11 ms
5,916 KB
testcase_02 AC 11 ms
5,836 KB
testcase_03 AC 24 ms
7,996 KB
testcase_04 AC 174 ms
44,220 KB
testcase_05 AC 11 ms
5,968 KB
testcase_06 AC 11 ms
5,896 KB
testcase_07 AC 518 ms
141,240 KB
testcase_08 AC 12 ms
6,048 KB
testcase_09 AC 11 ms
6,092 KB
testcase_10 AC 11 ms
5,972 KB
testcase_11 AC 42 ms
11,116 KB
testcase_12 AC 11 ms
5,924 KB
testcase_13 AC 60 ms
16,392 KB
testcase_14 AC 18 ms
6,784 KB
testcase_15 AC 55 ms
14,852 KB
testcase_16 AC 11 ms
5,980 KB
testcase_17 AC 11 ms
5,932 KB
testcase_18 AC 168 ms
45,596 KB
testcase_19 AC 54 ms
15,184 KB
testcase_20 AC 18 ms
7,060 KB
testcase_21 AC 20 ms
7,236 KB
testcase_22 AC 39 ms
11,412 KB
testcase_23 AC 13 ms
6,432 KB
testcase_24 AC 23 ms
7,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python
mod = int(1e9) + 7

def f(n, k):
    dp = [[0 for _ in xrange(n+1)] for _ in xrange(k+1)]
    dp[0][0] = 1
    for i in xrange(1, k+1):
        for j in xrange(n+1):
            if j - i >= 0:
                dp[i][j] = dp[i-1][j] + dp[i][j-i]
            else:
                dp[i][j] = dp[i-1][j]
    return dp[k][n]

n, s, k = map(int, raw_input().split())
x = s - n * (n-1) / 2 * k
print f(x, n) % mod if x >= 0 else 0
0