結果
問題 |
No.2934 Digit Sum
|
ユーザー |
|
提出日時 | 2024-10-13 16:17:28 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 734 bytes |
コンパイル時間 | 537 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 89,732 KB |
最終ジャッジ日時 | 2024-10-13 16:17:33 |
合計ジャッジ時間 | 4,194 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 23 RE * 2 |
ソースコード
import sys sys.set_int_max_str_digits(10**7) n, K = map(int, input().split()) if K == 1: print(1) exit() now = [1] dp = [now] while sum(now) <= K: le = len(now) nex = [0] * (le + 9) for i in range(le): for j in range(10): nex[i + j] += now[i] now = nex[:] if len(now) > n + 1: now = now[: n + 1] dp.append(now) le = len(dp) ma = len(dp[-1]) for i in range(le): dp[i] += [0] * (ma - len(dp[i])) for j in range(len(dp[i]) - 1): dp[i][j + 1] += dp[i][j] ans = 0 for i in range(le - 2, -1, -1): for j in range(10): if dp[i][n - j] > K: ans = 10 * ans + j n -= j break K -= dp[i][n - j] print(ans)