結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー vwxyzvwxyz
提出日時 2023-02-02 05:24:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 842 ms / 3,000 ms
コード長 1,496 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 11,168 KB
実行使用メモリ 10,784 KB
最終ジャッジ日時 2023-09-14 13:56:56
合計ジャッジ時間 7,798 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
10,592 KB
testcase_01 AC 34 ms
10,464 KB
testcase_02 AC 41 ms
10,520 KB
testcase_03 AC 33 ms
10,536 KB
testcase_04 AC 33 ms
10,512 KB
testcase_05 AC 33 ms
10,520 KB
testcase_06 AC 34 ms
10,444 KB
testcase_07 AC 33 ms
10,440 KB
testcase_08 AC 33 ms
10,532 KB
testcase_09 AC 33 ms
10,524 KB
testcase_10 AC 34 ms
10,516 KB
testcase_11 AC 33 ms
10,444 KB
testcase_12 AC 35 ms
10,524 KB
testcase_13 AC 35 ms
10,444 KB
testcase_14 AC 36 ms
10,404 KB
testcase_15 AC 37 ms
10,452 KB
testcase_16 AC 37 ms
10,532 KB
testcase_17 AC 37 ms
10,524 KB
testcase_18 AC 40 ms
10,448 KB
testcase_19 AC 39 ms
10,572 KB
testcase_20 AC 39 ms
10,468 KB
testcase_21 AC 39 ms
10,528 KB
testcase_22 AC 40 ms
10,524 KB
testcase_23 AC 41 ms
10,512 KB
testcase_24 AC 41 ms
10,476 KB
testcase_25 AC 42 ms
10,448 KB
testcase_26 AC 41 ms
10,556 KB
testcase_27 AC 41 ms
10,512 KB
testcase_28 AC 42 ms
10,512 KB
testcase_29 AC 41 ms
10,544 KB
testcase_30 AC 97 ms
10,480 KB
testcase_31 AC 107 ms
10,588 KB
testcase_32 AC 196 ms
10,564 KB
testcase_33 AC 404 ms
10,552 KB
testcase_34 AC 758 ms
10,620 KB
testcase_35 AC 775 ms
10,672 KB
testcase_36 AC 789 ms
10,784 KB
testcase_37 AC 842 ms
10,592 KB
testcase_38 AC 775 ms
10,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0