結果

問題 No.1407 Kindness
ユーザー 👑 H20H20
提出日時 2021-02-26 22:56:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 527 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 82,788 KB
実行使用メモリ 100,348 KB
最終ジャッジ日時 2024-04-10 13:37:19
合計ジャッジ時間 4,207 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
52,816 KB
testcase_01 AC 31 ms
52,464 KB
testcase_02 AC 31 ms
52,656 KB
testcase_03 AC 31 ms
52,652 KB
testcase_04 AC 32 ms
52,956 KB
testcase_05 AC 32 ms
53,228 KB
testcase_06 AC 32 ms
52,592 KB
testcase_07 AC 32 ms
53,220 KB
testcase_08 AC 33 ms
53,976 KB
testcase_09 AC 34 ms
53,240 KB
testcase_10 AC 32 ms
52,672 KB
testcase_11 AC 32 ms
54,088 KB
testcase_12 AC 143 ms
97,704 KB
testcase_13 AC 73 ms
80,380 KB
testcase_14 AC 74 ms
80,148 KB
testcase_15 AC 129 ms
95,684 KB
testcase_16 AC 97 ms
88,336 KB
testcase_17 AC 93 ms
84,432 KB
testcase_18 AC 84 ms
84,072 KB
testcase_19 AC 121 ms
93,880 KB
testcase_20 AC 116 ms
90,836 KB
testcase_21 AC 60 ms
73,136 KB
testcase_22 AC 62 ms
74,012 KB
testcase_23 AC 115 ms
90,092 KB
testcase_24 AC 153 ms
99,952 KB
testcase_25 AC 84 ms
80,992 KB
testcase_26 AC 102 ms
87,360 KB
testcase_27 AC 55 ms
75,024 KB
testcase_28 AC 135 ms
95,168 KB
testcase_29 AC 50 ms
69,904 KB
testcase_30 AC 145 ms
97,624 KB
testcase_31 AC 71 ms
80,716 KB
testcase_32 AC 136 ms
94,428 KB
testcase_33 AC 82 ms
82,236 KB
testcase_34 AC 115 ms
89,840 KB
testcase_35 AC 76 ms
79,420 KB
testcase_36 AC 54 ms
69,584 KB
testcase_37 AC 134 ms
100,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product

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

def count(a):
    n = len(a)
    dp=[[0] * 2 for i in range(n+1)]
    dp[0][0]=1
    for i, less in product(range(n), (0,1)):
        max_d = 9 if less else int(a[i])
        for d in range(max_d+1):
            less_ = less or d < max_d
            dp[i + 1][less_] = (dp[i + 1][less_] + dp[i][less]*d)%mod
    return dp

dp = count(N)
ans = dp[-1][0]+dp[-1][1]
dp = count('9'*(len(N)-1))
for i in range(len(N)):
    ans = (ans+dp[i][0]+dp[i][1])%mod

print((ans-1)%mod)
0