結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー 👑 H20H20
提出日時 2021-02-26 20:04:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,003 ms / 3,000 ms
コード長 1,023 bytes
コンパイル時間 405 ms
コンパイル使用メモリ 82,036 KB
実行使用メモリ 128,164 KB
最終ジャッジ日時 2024-04-10 10:34:56
合計ジャッジ時間 13,292 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
62,804 KB
testcase_01 AC 54 ms
64,632 KB
testcase_02 AC 241 ms
79,428 KB
testcase_03 AC 37 ms
52,864 KB
testcase_04 AC 44 ms
61,392 KB
testcase_05 AC 44 ms
60,264 KB
testcase_06 AC 44 ms
60,884 KB
testcase_07 AC 43 ms
60,600 KB
testcase_08 AC 48 ms
61,208 KB
testcase_09 AC 47 ms
61,556 KB
testcase_10 AC 50 ms
64,412 KB
testcase_11 AC 49 ms
62,284 KB
testcase_12 AC 111 ms
77,200 KB
testcase_13 AC 107 ms
76,756 KB
testcase_14 AC 129 ms
77,524 KB
testcase_15 AC 166 ms
78,816 KB
testcase_16 AC 172 ms
78,824 KB
testcase_17 AC 195 ms
79,320 KB
testcase_18 AC 236 ms
80,000 KB
testcase_19 AC 226 ms
79,444 KB
testcase_20 AC 258 ms
80,464 KB
testcase_21 AC 270 ms
80,428 KB
testcase_22 AC 269 ms
80,636 KB
testcase_23 AC 273 ms
80,708 KB
testcase_24 AC 250 ms
79,972 KB
testcase_25 AC 272 ms
80,584 KB
testcase_26 AC 273 ms
80,036 KB
testcase_27 AC 274 ms
80,588 KB
testcase_28 AC 284 ms
80,132 KB
testcase_29 AC 290 ms
80,616 KB
testcase_30 AC 418 ms
85,872 KB
testcase_31 AC 365 ms
86,016 KB
testcase_32 AC 502 ms
91,356 KB
testcase_33 AC 626 ms
103,928 KB
testcase_34 AC 991 ms
126,548 KB
testcase_35 AC 987 ms
128,056 KB
testcase_36 AC 1,003 ms
128,164 KB
testcase_37 AC 976 ms
126,760 KB
testcase_38 AC 803 ms
125,780 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(3)] for j in range(3)] for k in range(2)] for l in range(n+1)]
    dp[0][0][0][0][0] = 1

    for i, less, divcnt5, divcnt2, has0 in product(range(n), (0,1), range(3), range(3), (0,1)):
        max_d = 9 if less else int(a[i])
        for d in range(max_d+1):
            less_ = less or d < max_d
            divcnt5_ = min(2,divcnt5+(d==5))
            if d==4 or d==8:
                divcnt2_=2
            elif d==2 or d==6:
                divcnt2_=min(2,divcnt2+1)
            else:
                divcnt2_ = divcnt2
            has0_ = has0 or d==0
            dp[i + 1][less_][divcnt5_][divcnt2_][has0_] = (dp[i + 1][less_][divcnt5_][divcnt2_][has0_] + dp[i][less][divcnt5][divcnt2][has0])%mod

    return dp

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