結果

問題 No.269 見栄っ張りの募金活動
ユーザー susami-jpgsusami-jpg
提出日時 2022-03-16 12:04:00
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 2,341 bytes
コンパイル時間 648 ms
コンパイル使用メモリ 81,560 KB
実行使用メモリ 104,252 KB
最終ジャッジ日時 2023-10-24 16:50:39
合計ジャッジ時間 9,137 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,452 KB
testcase_01 AC 39 ms
55,452 KB
testcase_02 AC 183 ms
77,176 KB
testcase_03 AC 2,225 ms
104,252 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 #

from sys import exit, stdin, setrecursionlimit
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush, heapify
#from itertools import permutations, combinations, accumulate
#from math import sqrt, factorial
#math.log(x, y)はyを底としたxの対数を返す。
#数学ではlogとかlnで表される自然対数(ネイピア数eを底とする対数)は、math.log(x)で計算できる。
#二進対数(2を底とする対数)は、math.log2(x)で計算できる。math.log(x, 2)よりも正確な値となる。
#常用対数(10を底とする対数)は、math.log10(x)で計算できる。math.log(x, 10)よりも正確な値となる。
#from decimal import Decimal, ROUND_HALF_UP
#decimalには文字列で渡す PyPyは遅いのでPython3で提出する
#d1 = Decimal('1.1') d2 = Decimal('2.3') -> d1 + d2などの演算で浮動小数点数での誤差がなくなる(割り算もok)
#四捨五入: dをDecimalオブジェクトとして、d.quantize(Decimal('1'), rounding=ROUND_HALF_UP)) (1にすると整数を返し、0.1にすると小数第一位で四捨五入)
INF = 10**18
MOD = 10**9+7
MOD2 = 998244353
eps = 0.0000000001
setrecursionlimit(10**7)
#pypyでの再帰TLE対策(自分の環境では使えないので提出時のみコメントアウトするように注意)
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')
#list複数行読み込み高速化 改行、空白区切り注意
#[list(map(int, stdin.readline().split())) for _ in range(M)]
#複数行読み込み 行ごとに文字列として読み込む ex) ['9 2 6 5 3', '改行', '5 8 9 7 9', '改行'] 改行区切りなのと空白区切りをsplitする必要があるので注意
#query = stdin.readlines()

N, S, K = map(int, input().split())
#dfs(i, T):= i番目の支払金額まで決まっていて、残額がT円の時の支払う場合の数
rec = dict()
def dfs(i, T):
    if (i, T) in rec:return rec[(i, T)]
    if i == 0:
        if T == 0:return 1
        else:return 0
    res = 0
    if i == 1 and T == 0:res += dfs(i-1, T)%MOD
    for k in range(K, INF):
        nT = T - k*(N-i+1)
        if nT < 0:break
        res += dfs(i-1, nT)
        res %= MOD
    rec[(i, T)] = res
    return res

print(dfs(N, S))
0