結果

問題 No.1407 Kindness
ユーザー tktk_snsntktk_snsn
提出日時 2021-02-26 21:45:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 635 ms / 2,000 ms
コード長 757 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 170,572 KB
最終ジャッジ日時 2024-04-10 12:23:04
合計ジャッジ時間 10,156 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
52,268 KB
testcase_01 AC 38 ms
62,552 KB
testcase_02 AC 35 ms
59,856 KB
testcase_03 AC 31 ms
52,916 KB
testcase_04 AC 36 ms
59,940 KB
testcase_05 AC 36 ms
61,048 KB
testcase_06 AC 35 ms
60,108 KB
testcase_07 AC 34 ms
60,664 KB
testcase_08 AC 35 ms
59,684 KB
testcase_09 AC 36 ms
59,804 KB
testcase_10 AC 35 ms
60,820 KB
testcase_11 AC 35 ms
61,492 KB
testcase_12 AC 595 ms
160,544 KB
testcase_13 AC 175 ms
94,988 KB
testcase_14 AC 211 ms
100,612 KB
testcase_15 AC 533 ms
152,716 KB
testcase_16 AC 353 ms
123,588 KB
testcase_17 AC 253 ms
108,260 KB
testcase_18 AC 244 ms
106,300 KB
testcase_19 AC 489 ms
144,932 KB
testcase_20 AC 418 ms
133,732 KB
testcase_21 AC 93 ms
80,896 KB
testcase_22 AC 104 ms
83,128 KB
testcase_23 AC 397 ms
130,712 KB
testcase_24 AC 635 ms
169,496 KB
testcase_25 AC 249 ms
106,760 KB
testcase_26 AC 335 ms
119,404 KB
testcase_27 AC 95 ms
81,812 KB
testcase_28 AC 522 ms
151,688 KB
testcase_29 AC 74 ms
78,844 KB
testcase_30 AC 583 ms
159,744 KB
testcase_31 AC 174 ms
95,424 KB
testcase_32 AC 533 ms
146,708 KB
testcase_33 AC 226 ms
101,800 KB
testcase_34 AC 410 ms
129,412 KB
testcase_35 AC 201 ms
97,204 KB
testcase_36 AC 69 ms
73,772 KB
testcase_37 AC 578 ms
170,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10 ** 9 + 7
S = input()
N = len(S)

dp = [[[0] * 2 for _ in range(10)] for _ in range(N + 1)]
dp[0][0][0] = 1
for i, s in enumerate(S):
    nd = int(s)
    for j in range(10):
        for k in range(2):
            for d in range(10):
                ni = i + 1
                nj = d
                nk = k
                if nk == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k] * d
                dp[ni][nj][nk] %= mod

ans = 0
for i in range(10):
    for j in range(2):
        ans += dp[N][i][j]
        ans %= mod

add = 45
for i in range(N - 1):
    ans += add
    ans %= mod
    add *= 45
    add %= mod

print(ans)
0