結果
| 問題 |
No.41 貯金箱の溜息(EASY)
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-26 15:47:13 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 67 ms / 5,000 ms |
| コード長 | 800 bytes |
| コンパイル時間 | 158 ms |
| コンパイル使用メモリ | 82,760 KB |
| 実行使用メモリ | 70,016 KB |
| 最終ジャッジ日時 | 2025-03-26 15:47:22 |
| 合計ジャッジ時間 | 845 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 |
ソースコード
MOD = 10**9 + 9
# Precompute the maximum required k_max based on constraints analysis
max_k = 10**5 # Sufficient for M up to 1e10
# Initialize dp array
dp = [0] * (max_k + 1)
dp[0] = 1
# Fill dp using dynamic programming
for i in range(1, 10): # i represents the multiplier for 111111
for j in range(i, max_k + 1):
dp[j] = (dp[j] + dp[j - i]) % MOD
# Compute prefix sums
prefix_sum = [0] * (max_k + 1)
current_sum = 0
for k in range(max_k + 1):
current_sum = (current_sum + dp[k]) % MOD
prefix_sum[k] = current_sum
# Read input and process each test case
import sys
input = sys.stdin.read().split()
T = int(input[0])
cases = list(map(int, input[1:T+1]))
for M in cases:
k_max = M // 111111
if k_max > max_k:
k_max = max_k
print(prefix_sum[k_max] % MOD)
lam6er