結果

問題 No.1407 Kindness
ユーザー rlangevinrlangevin
提出日時 2023-03-23 12:24:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 222 ms / 2,000 ms
コード長 751 bytes
コンパイル時間 944 ms
コンパイル使用メモリ 81,736 KB
実行使用メモリ 83,324 KB
最終ジャッジ日時 2023-10-18 19:29:46
合計ジャッジ時間 5,902 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,576 KB
testcase_01 AC 39 ms
53,576 KB
testcase_02 AC 39 ms
53,576 KB
testcase_03 AC 38 ms
53,576 KB
testcase_04 AC 38 ms
53,576 KB
testcase_05 AC 38 ms
53,576 KB
testcase_06 AC 38 ms
53,576 KB
testcase_07 AC 38 ms
53,576 KB
testcase_08 AC 38 ms
53,576 KB
testcase_09 AC 38 ms
53,576 KB
testcase_10 AC 38 ms
53,576 KB
testcase_11 AC 38 ms
53,576 KB
testcase_12 AC 174 ms
82,652 KB
testcase_13 AC 93 ms
76,776 KB
testcase_14 AC 103 ms
77,288 KB
testcase_15 AC 174 ms
81,728 KB
testcase_16 AC 135 ms
79,416 KB
testcase_17 AC 117 ms
78,100 KB
testcase_18 AC 116 ms
77,948 KB
testcase_19 AC 164 ms
81,336 KB
testcase_20 AC 147 ms
80,100 KB
testcase_21 AC 82 ms
76,228 KB
testcase_22 AC 86 ms
76,492 KB
testcase_23 AC 149 ms
80,036 KB
testcase_24 AC 191 ms
83,324 KB
testcase_25 AC 109 ms
78,000 KB
testcase_26 AC 130 ms
79,340 KB
testcase_27 AC 82 ms
76,228 KB
testcase_28 AC 168 ms
81,712 KB
testcase_29 AC 79 ms
76,228 KB
testcase_30 AC 181 ms
82,640 KB
testcase_31 AC 100 ms
76,804 KB
testcase_32 AC 222 ms
81,312 KB
testcase_33 AC 125 ms
77,304 KB
testcase_34 AC 186 ms
79,440 KB
testcase_35 AC 111 ms
76,820 KB
testcase_36 AC 75 ms
76,012 KB
testcase_37 AC 94 ms
83,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = list(input())
S = list(map(int, S))
mod = 10 ** 9 + 7
N = len(S)
pre = [[0] * 2 for i in range(2)]
pre[0][0] = 1
for i in range(N):
    dp = [[0] * 2 for i in range(2)]
    for j in range(10):
        if j == 0:
            dp[0][1] = pre[0][0] + pre[0][1]
        elif j < S[i]:
            dp[1][1] += (sum(pre[0]) + sum(pre[1])) * j
        elif j == S[i]:
            dp[1][0] += (pre[0][0] + pre[1][0]) * j
            dp[1][1] += (pre[0][1] + pre[1][1]) * j
        else:
            dp[1][1] += (pre[0][1] + pre[1][1]) * j
    for a in range(2):
        for b in range(2):
            dp[a][b] %= mod
    dp, pre = pre, dp

ans = 0
for a in range(2):
    for b in range(2):
        ans += pre[a][b]
        ans %= mod
print( (ans-1) % mod )
0