結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー vwxyzvwxyz
提出日時 2023-02-02 05:10:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,407 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 86,776 KB
実行使用メモリ 95,564 KB
最終ジャッジ日時 2023-09-14 13:47:42
合計ジャッジ時間 13,167 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 251 ms
91,152 KB
testcase_01 AC 252 ms
91,172 KB
testcase_02 AC 269 ms
94,280 KB
testcase_03 AC 247 ms
91,048 KB
testcase_04 AC 252 ms
90,996 KB
testcase_05 AC 250 ms
90,980 KB
testcase_06 AC 251 ms
91,124 KB
testcase_07 AC 252 ms
90,832 KB
testcase_08 AC 251 ms
91,172 KB
testcase_09 AC 253 ms
91,048 KB
testcase_10 AC 250 ms
90,968 KB
testcase_11 AC 251 ms
91,156 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 264 ms
93,720 KB
testcase_15 WA -
testcase_16 AC 269 ms
93,512 KB
testcase_17 AC 271 ms
94,044 KB
testcase_18 AC 268 ms
94,076 KB
testcase_19 WA -
testcase_20 AC 265 ms
93,900 KB
testcase_21 WA -
testcase_22 AC 268 ms
93,912 KB
testcase_23 AC 268 ms
93,752 KB
testcase_24 AC 271 ms
93,836 KB
testcase_25 AC 270 ms
93,800 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 271 ms
94,036 KB
testcase_29 AC 269 ms
94,020 KB
testcase_30 AC 281 ms
94,444 KB
testcase_31 AC 280 ms
94,512 KB
testcase_32 AC 302 ms
95,564 KB
testcase_33 RE -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 301 ms
95,176 KB
testcase_38 AC 293 ms
94,960 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]
    cnt5+=C5[n]
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