結果

問題 No.1407 Kindness
ユーザー convexineqconvexineq
提出日時 2021-02-27 06:13:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 211 ms / 2,000 ms
コード長 624 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 82,320 KB
実行使用メモリ 101,404 KB
最終ジャッジ日時 2024-04-10 15:11:06
合計ジャッジ時間 5,192 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,748 KB
testcase_01 AC 32 ms
52,616 KB
testcase_02 AC 32 ms
52,760 KB
testcase_03 AC 30 ms
52,160 KB
testcase_04 AC 31 ms
52,128 KB
testcase_05 AC 31 ms
53,056 KB
testcase_06 AC 33 ms
52,068 KB
testcase_07 AC 32 ms
53,212 KB
testcase_08 AC 32 ms
52,440 KB
testcase_09 AC 33 ms
53,528 KB
testcase_10 AC 33 ms
54,024 KB
testcase_11 AC 32 ms
52,660 KB
testcase_12 AC 195 ms
99,116 KB
testcase_13 AC 105 ms
80,836 KB
testcase_14 AC 117 ms
82,944 KB
testcase_15 AC 191 ms
96,912 KB
testcase_16 AC 145 ms
89,120 KB
testcase_17 AC 121 ms
85,444 KB
testcase_18 AC 121 ms
85,052 KB
testcase_19 AC 180 ms
95,112 KB
testcase_20 AC 167 ms
92,104 KB
testcase_21 AC 83 ms
78,512 KB
testcase_22 AC 76 ms
78,160 KB
testcase_23 AC 153 ms
90,912 KB
testcase_24 AC 211 ms
101,144 KB
testcase_25 AC 123 ms
85,252 KB
testcase_26 AC 139 ms
87,720 KB
testcase_27 AC 84 ms
78,640 KB
testcase_28 AC 183 ms
96,340 KB
testcase_29 AC 75 ms
77,208 KB
testcase_30 AC 197 ms
98,884 KB
testcase_31 AC 103 ms
81,468 KB
testcase_32 AC 201 ms
95,048 KB
testcase_33 AC 122 ms
83,308 KB
testcase_34 AC 174 ms
90,840 KB
testcase_35 AC 107 ms
81,996 KB
testcase_36 AC 69 ms
77,040 KB
testcase_37 AC 176 ms
101,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = input()
MOD = 10**9+7
dp = [[[0 for _ in range(2)] for _ in range(2)] for _ in range(len(n)+1)] # 上からi桁まで、is_less, 0埋めか?
 
dp[0][0][0] = 1
for i,ni in enumerate(n): #i桁目からi+1桁目に遷移
    ni = int(ni)
    for is_non0 in range(2):
        for is_less in range(2):#1 なら真に小さい
            for d in range(10 if is_less else ni+1): # d: i+1桁目の数字
                dp[i+1][is_less or d < ni][is_non0 or d!=0] += dp[i][is_less][is_non0]*(d if is_non0 or d else 1)
                dp[i+1][is_less or d < ni][is_non0 or d!=0] %= MOD

print((dp[-1][0][1]+dp[-1][1][1])%MOD)
0