結果

問題 No.1407 Kindness
ユーザー convexineqconvexineq
提出日時 2021-02-27 06:12:38
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 618 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 102,432 KB
最終ジャッジ日時 2023-07-26 00:11:04
合計ジャッジ時間 9,051 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,276 KB
testcase_01 AC 78 ms
71,284 KB
testcase_02 AC 75 ms
71,548 KB
testcase_03 AC 73 ms
71,356 KB
testcase_04 AC 74 ms
71,212 KB
testcase_05 AC 72 ms
71,164 KB
testcase_06 AC 71 ms
71,356 KB
testcase_07 AC 72 ms
71,212 KB
testcase_08 AC 75 ms
71,276 KB
testcase_09 AC 75 ms
71,324 KB
testcase_10 AC 71 ms
71,508 KB
testcase_11 AC 72 ms
71,080 KB
testcase_12 AC 290 ms
100,044 KB
testcase_13 AC 150 ms
82,584 KB
testcase_14 AC 163 ms
84,248 KB
testcase_15 AC 264 ms
97,848 KB
testcase_16 AC 207 ms
90,064 KB
testcase_17 AC 173 ms
86,216 KB
testcase_18 AC 175 ms
85,844 KB
testcase_19 AC 243 ms
96,036 KB
testcase_20 AC 224 ms
93,060 KB
testcase_21 AC 125 ms
79,468 KB
testcase_22 AC 121 ms
78,772 KB
testcase_23 AC 217 ms
91,948 KB
testcase_24 AC 293 ms
102,432 KB
testcase_25 AC 176 ms
85,544 KB
testcase_26 AC 196 ms
88,948 KB
testcase_27 AC 128 ms
79,340 KB
testcase_28 AC 260 ms
97,476 KB
testcase_29 AC 118 ms
78,528 KB
testcase_30 AC 266 ms
99,616 KB
testcase_31 AC 146 ms
82,592 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 227 ms
91,428 KB
testcase_35 AC 152 ms
82,988 KB
testcase_36 AC 109 ms
78,248 KB
testcase_37 AC 250 ms
102,116 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])
0