結果

問題 No.269 見栄っ張りの募金活動
ユーザー ntudantuda
提出日時 2021-10-14 20:37:06
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 532 bytes
コンパイル時間 766 ms
コンパイル使用メモリ 81,748 KB
実行使用メモリ 97,592 KB
最終ジャッジ日時 2023-10-17 19:25:04
合計ジャッジ時間 8,125 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,488 KB
testcase_01 AC 45 ms
55,632 KB
testcase_02 AC 38 ms
53,488 KB
testcase_03 AC 656 ms
97,592 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
N, S, K = map(int, input().split())
D = S - N * (N - 1) * K // 2

if D < 0:
    print(0)
    sys.exit()
elif D == 0:
    print(1)
    sys.exit()

mod = 10 ** 9 + 7

from functools import lru_cache
@lru_cache(maxsize=None)
def dfs(a, x):  # a:割り振り数、b:min数、x:残り人数、返り値パターン数%mod
    global mod
    ans = 0
    if x == 2:
        return a//2 + 1
    for i in range(a // x + 1):
        ans = (ans + dfs(a - i * x, x - 1)) % mod
    #print(a,b,x,ans)
    return ans


print(dfs(D, N))
0