結果
| 問題 | No.1417 100の倍数かつ正整数(2) | 
| コンテスト | |
| ユーザー |  vwxyz | 
| 提出日時 | 2023-02-02 05:24:12 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 980 ms / 3,000 ms | 
| コード長 | 1,496 bytes | 
| コンパイル時間 | 88 ms | 
| コンパイル使用メモリ | 12,800 KB | 
| 実行使用メモリ | 12,288 KB | 
| 最終ジャッジ日時 | 2024-07-01 21:19:27 | 
| 合計ジャッジ時間 | 8,292 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 36 | 
ソースコード
import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines
write=sys.stdout.write
N=list(map(int,list(readline().rstrip())))
mod=10**9+7
C2=[-1,0,1,0,2,0,1,0,2,0]
C5=[-1,0,0,0,0,1,0,0,0,0]
dp=[0]*9
for i in range(1,N[0]):
    dp[C2[i]*3+C5[i]]+=1
cnt2,cnt5=C2[N[0]],C5[N[0]]
bl=True
for n in N[1:]:
    prev=dp
    dp=[0]*9
    for c2 in range(3):
        for c5 in range(3):
            for i in range(1,10):
                dp[min(c2+C2[i],2)*3+min(c5+C5[i],2)]+=prev[c2*3+c5]
    for c2c5 in range(9):
        dp[c2c5]%=mod
    for i in range(1,10):
        dp[C2[i]*3+C5[i]]+=1
    if bl:
        for i in range(1,n):
            dp[min(C2[i]+cnt2,2)*3+min(C5[i]+cnt5,2)]+=1
    
    cnt2+=C2[n]
    cnt2=min(cnt2,2)
    cnt5+=C5[n]
    cnt5=min(cnt5,2)
    bl&=(n!=0)
ans=dp[8]
if not 0 in N and sum(C2[n] for n in N)>=2 and sum(C5[n] for n in N)>=2:
    ans+=1
ans%=mod
print(ans)
            
            
            
        