結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー 👑 H20H20
提出日時 2021-02-23 20:50:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 472 ms / 3,000 ms
コード長 860 bytes
コンパイル時間 1,108 ms
コンパイル使用メモリ 81,092 KB
実行使用メモリ 101,232 KB
最終ジャッジ日時 2023-10-25 04:55:12
合計ジャッジ時間 7,787 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,092 KB
testcase_01 AC 48 ms
61,300 KB
testcase_02 AC 95 ms
76,072 KB
testcase_03 AC 38 ms
53,224 KB
testcase_04 AC 38 ms
53,224 KB
testcase_05 AC 39 ms
53,224 KB
testcase_06 AC 39 ms
53,224 KB
testcase_07 AC 43 ms
59,428 KB
testcase_08 AC 45 ms
59,280 KB
testcase_09 AC 44 ms
59,280 KB
testcase_10 AC 45 ms
59,528 KB
testcase_11 AC 38 ms
53,224 KB
testcase_12 AC 67 ms
70,688 KB
testcase_13 AC 70 ms
70,812 KB
testcase_14 AC 73 ms
72,912 KB
testcase_15 AC 99 ms
75,920 KB
testcase_16 AC 100 ms
75,936 KB
testcase_17 AC 101 ms
75,936 KB
testcase_18 AC 119 ms
76,672 KB
testcase_19 AC 110 ms
76,552 KB
testcase_20 AC 114 ms
76,476 KB
testcase_21 AC 125 ms
76,688 KB
testcase_22 AC 126 ms
76,808 KB
testcase_23 AC 127 ms
76,884 KB
testcase_24 AC 103 ms
75,928 KB
testcase_25 AC 129 ms
76,892 KB
testcase_26 AC 129 ms
76,768 KB
testcase_27 AC 127 ms
76,780 KB
testcase_28 AC 133 ms
76,908 KB
testcase_29 AC 133 ms
76,952 KB
testcase_30 AC 203 ms
79,416 KB
testcase_31 AC 147 ms
78,888 KB
testcase_32 AC 234 ms
82,160 KB
testcase_33 AC 286 ms
89,328 KB
testcase_34 AC 458 ms
100,444 KB
testcase_35 AC 451 ms
101,232 KB
testcase_36 AC 472 ms
100,736 KB
testcase_37 AC 468 ms
99,956 KB
testcase_38 AC 315 ms
99,400 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][1] = 1
    candiv2=[0,0,1,0,2,0,1,0,3,0]

    for i, less, divcnt5, divcnt2, lzero 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):
            if lzero==0 and d==0:
                continue
            less_ = less or d < max_d
            divcnt5_ = min(2,divcnt5+(d==5))
            divcnt2_ = min(2,divcnt2+candiv2[d])
            lzero_ = lzero and d==0
            dp[i + 1][less_][divcnt5_][divcnt2_][lzero_] = (dp[i + 1][less_][divcnt5_][divcnt2_][lzero_] + dp[i][less][divcnt5][divcnt2][lzero])%mod

    return (dp[n][0][2][2][0]+dp[n][1][2][2][0])%mod

print(count(N))
0