結果
| 問題 |
No.269 見栄っ張りの募金活動
|
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2021-10-14 20:37:06 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 532 bytes |
| コンパイル時間 | 282 ms |
| コンパイル使用メモリ | 82,276 KB |
| 実行使用メモリ | 97,368 KB |
| 最終ジャッジ日時 | 2024-09-17 16:35:30 |
| 合計ジャッジ時間 | 7,711 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 1 TLE * 1 -- * 20 |
ソースコード
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))
ntuda