結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー vwxyzvwxyz
提出日時 2023-02-02 05:11:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,449 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 10,976 KB
実行使用メモリ 10,696 KB
最終ジャッジ日時 2023-09-14 13:47:52
合計ジャッジ時間 7,302 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
10,476 KB
testcase_01 AC 34 ms
10,532 KB
testcase_02 AC 41 ms
10,460 KB
testcase_03 AC 32 ms
10,472 KB
testcase_04 AC 33 ms
10,488 KB
testcase_05 AC 33 ms
10,492 KB
testcase_06 AC 32 ms
10,472 KB
testcase_07 AC 33 ms
10,456 KB
testcase_08 AC 33 ms
10,388 KB
testcase_09 AC 33 ms
10,376 KB
testcase_10 AC 32 ms
10,380 KB
testcase_11 AC 33 ms
10,552 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 36 ms
10,468 KB
testcase_15 WA -
testcase_16 AC 38 ms
10,516 KB
testcase_17 AC 38 ms
10,496 KB
testcase_18 AC 38 ms
10,480 KB
testcase_19 WA -
testcase_20 AC 39 ms
10,456 KB
testcase_21 WA -
testcase_22 AC 40 ms
10,464 KB
testcase_23 AC 42 ms
10,456 KB
testcase_24 AC 40 ms
10,460 KB
testcase_25 AC 41 ms
10,556 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 42 ms
10,536 KB
testcase_29 AC 43 ms
10,384 KB
testcase_30 AC 96 ms
10,540 KB
testcase_31 AC 111 ms
10,660 KB
testcase_32 AC 189 ms
10,440 KB
testcase_33 RE -
testcase_34 RE -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 846 ms
10,556 KB
testcase_38 AC 797 ms
10,620 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=[0,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]]

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

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