結果
| 問題 | No.1417 100の倍数かつ正整数(2) | 
| コンテスト | |
| ユーザー |  Kude | 
| 提出日時 | 2021-03-05 22:48:04 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 96 ms / 3,000 ms | 
| コード長 | 1,186 bytes | 
| コンパイル時間 | 182 ms | 
| コンパイル使用メモリ | 82,116 KB | 
| 実行使用メモリ | 76,908 KB | 
| 最終ジャッジ日時 | 2024-10-07 03:45:01 | 
| 合計ジャッジ時間 | 3,010 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 36 | 
ソースコード
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)
            
            
            
        