結果

問題 No.269 見栄っ張りの募金活動
ユーザー mkawa2
提出日時 2020-02-05 00:32:25
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 3,469 ms / 5,000 ms
コード長 488 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 330,448 KB
最終ジャッジ日時 2024-09-21 07:53:00
合計ジャッジ時間 8,704 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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