結果

問題 No.269 見栄っ張りの募金活動
ユーザー 👑 kmjpkmjp
提出日時 2015-04-08 02:08:52
言語 Python2
(2.7.18)
結果
AC  
実行時間 1,753 ms / 5,000 ms
コード長 785 bytes
コンパイル時間 81 ms
コンパイル使用メモリ 6,736 KB
実行使用メモリ 76,932 KB
最終ジャッジ日時 2023-09-23 01:02:29
合計ジャッジ時間 12,218 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 197 ms
31,852 KB
testcase_01 AC 202 ms
31,704 KB
testcase_02 AC 212 ms
31,792 KB
testcase_03 AC 301 ms
32,232 KB
testcase_04 AC 774 ms
47,368 KB
testcase_05 AC 200 ms
31,912 KB
testcase_06 AC 198 ms
31,852 KB
testcase_07 AC 1,753 ms
76,932 KB
testcase_08 AC 199 ms
31,900 KB
testcase_09 AC 845 ms
33,296 KB
testcase_10 AC 203 ms
31,848 KB
testcase_11 AC 337 ms
34,432 KB
testcase_12 AC 696 ms
31,708 KB
testcase_13 AC 381 ms
35,936 KB
testcase_14 AC 215 ms
31,720 KB
testcase_15 AC 363 ms
35,540 KB
testcase_16 AC 657 ms
32,804 KB
testcase_17 AC 281 ms
31,904 KB
testcase_18 AC 1,136 ms
50,556 KB
testcase_19 AC 431 ms
36,000 KB
testcase_20 AC 227 ms
31,816 KB
testcase_21 AC 223 ms
31,704 KB
testcase_22 AC 298 ms
33,700 KB
testcase_23 AC 216 ms
31,848 KB
testcase_24 AC 240 ms
31,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
import sys
import math

N,S,K=map(int,raw_input().strip().split())
DP=[[0 for i in range(30005)] for j in range(105)]

mo = 1000000007

# 1人目だけは任意の(Nの倍数)円を寄付できる
for k in range(0,S+N,N):
	DP[1][k] = 1

# i番目の人
for i in range(2,N+1):
	# i番目の人が、(i-1)番の人より1円余分に払うと
	# 以降の人全体で(N+1-i)円払うことになる
	mult = N+1-i
	
	# t円にできるか?
	for t in range(0,S+1):
		# (i-1)番の人よりも最低K円余分に払う
		if t >= K*mult:
			DP[i][t] += DP[i-1][t - K*mult]
		
		# 既に全体(t-mult)円払っているが
		# もう1円(全体でmult円)余分に払うケース
		if t - mult >= 0:
			DP[i][t] += DP[i][t-mult]
		
		DP[i][t] %= mo

print DP[N][S]

0