結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー KudeKude
提出日時 2021-03-05 22:48:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 114 ms / 3,000 ms
コード長 1,186 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 76,928 KB
最終ジャッジ日時 2024-04-16 10:35:32
合計ジャッジ時間 3,305 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
52,096 KB
testcase_01 AC 42 ms
52,352 KB
testcase_02 AC 43 ms
53,120 KB
testcase_03 AC 40 ms
52,224 KB
testcase_04 AC 46 ms
52,096 KB
testcase_05 AC 40 ms
52,096 KB
testcase_06 AC 40 ms
52,352 KB
testcase_07 AC 41 ms
52,480 KB
testcase_08 AC 40 ms
52,224 KB
testcase_09 AC 41 ms
52,352 KB
testcase_10 AC 40 ms
52,352 KB
testcase_11 AC 41 ms
52,224 KB
testcase_12 AC 41 ms
52,352 KB
testcase_13 AC 41 ms
52,480 KB
testcase_14 AC 42 ms
52,224 KB
testcase_15 AC 42 ms
52,480 KB
testcase_16 AC 43 ms
52,608 KB
testcase_17 AC 43 ms
52,992 KB
testcase_18 AC 43 ms
53,120 KB
testcase_19 AC 43 ms
52,736 KB
testcase_20 AC 43 ms
53,376 KB
testcase_21 AC 43 ms
53,376 KB
testcase_22 AC 44 ms
54,016 KB
testcase_23 AC 44 ms
53,376 KB
testcase_24 AC 44 ms
53,504 KB
testcase_25 AC 44 ms
53,760 KB
testcase_26 AC 44 ms
53,120 KB
testcase_27 AC 44 ms
53,632 KB
testcase_28 AC 44 ms
53,376 KB
testcase_29 AC 45 ms
53,504 KB
testcase_30 AC 87 ms
74,112 KB
testcase_31 AC 71 ms
68,480 KB
testcase_32 AC 114 ms
76,800 KB
testcase_33 AC 79 ms
73,728 KB
testcase_34 AC 97 ms
76,928 KB
testcase_35 AC 97 ms
76,672 KB
testcase_36 AC 97 ms
76,800 KB
testcase_37 AC 101 ms
76,672 KB
testcase_38 AC 83 ms
76,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
s = list(map(int, input()))
n = len(s)
dp = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
cnt2 = cnt5 = cnt0 = 0
for i in range(n):
    ndp = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
    for a in range(3):
        for b in range(3):
            ndp[a][b] += 4 * dp[a][b]
            ndp[2][b] += 2 * dp[a][b]
            ndp[min(2, a + 1)][b] += 2 * dp[a][b]
            ndp[a][min(2, b + 1)] += dp[a][b]
    if i != 0:
        ndp[1][0] += 2
        ndp[2][0] += 2
        ndp[0][1] += 1
        ndp[0][0] += 4
    if not cnt0:
        for d in range(1, s[i]):
            t2 = cnt2
            t5 = cnt5
            while d % 2 == 0:
                d //= 2
                t2 += 1
            if d % 5 == 0:
                d //= 5
                t5 += 1
            t2 = min(2, t2)
            t5 = min(2, t5)
            ndp[t2][t5] += 1
    for a in range(3):
        for b in range(3):
            ndp[a][b] %= MOD
    if s[i] == 0:
        cnt0 += 1
    elif s[i] % 4 == 0:
        cnt2 += 2
    elif s[i] % 2 == 0:
        cnt2 += 1
    elif s[i] == 5:
        cnt5 += 1
    dp = ndp
ans = dp[2][2]
if not cnt0 and cnt2 >= 2 and cnt5 >= 2:
    ans = (ans + 1) % MOD
print(ans)
0