結果

問題 No.269 見栄っ張りの募金活動
ユーザー mkawa2mkawa2
提出日時 2020-02-05 00:32:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 3,034 ms / 5,000 ms
コード長 488 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 11,980 KB
実行使用メモリ 329,944 KB
最終ジャッジ日時 2023-10-21 06:43:16
合計ジャッジ時間 8,100 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,020 KB
testcase_01 AC 25 ms
10,020 KB
testcase_02 AC 26 ms
10,020 KB
testcase_03 AC 80 ms
18,712 KB
testcase_04 AC 999 ms
113,892 KB
testcase_05 AC 29 ms
10,316 KB
testcase_06 AC 26 ms
10,020 KB
testcase_07 AC 3,034 ms
329,944 KB
testcase_08 AC 48 ms
10,032 KB
testcase_09 AC 27 ms
10,016 KB
testcase_10 AC 27 ms
10,016 KB
testcase_11 AC 190 ms
31,036 KB
testcase_12 AC 26 ms
10,016 KB
testcase_13 AC 314 ms
47,040 KB
testcase_14 AC 35 ms
12,036 KB
testcase_15 AC 277 ms
47,156 KB
testcase_16 AC 26 ms
10,016 KB
testcase_17 AC 26 ms
10,016 KB
testcase_18 AC 930 ms
110,752 KB
testcase_19 AC 262 ms
46,836 KB
testcase_20 AC 54 ms
14,912 KB
testcase_21 AC 48 ms
14,568 KB
testcase_22 AC 174 ms
29,976 KB
testcase_23 AC 37 ms
12,168 KB
testcase_24 AC 76 ms
19,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
def MI(): return map(int, sys.stdin.readline().split())

md = 10 ** 9 + 7
def main():
    # n人でx円払う方法
    memo = {}

    def p(n, x):
        if x<0:return 0
        if n == 1: return 1
        if (n, x) in memo: return memo[n, x]
        res = p(n - 1, x)
        if x - n >= 0: res += p(n, x - n)
        res %= md
        memo[n, x] = res
        return res

    n, s, k = MI()
    print(p(n, s - k * n * (n - 1) // 2))

main()
0