結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,404 KB
testcase_01 AC 34 ms
10,372 KB
testcase_02 AC 41 ms
10,436 KB
testcase_03 AC 33 ms
10,380 KB
testcase_04 AC 34 ms
10,424 KB
testcase_05 AC 33 ms
10,404 KB
testcase_06 WA -
testcase_07 AC 33 ms
10,504 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 34 ms
10,516 KB
testcase_11 AC 35 ms
10,460 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 37 ms
10,384 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 37 ms
10,400 KB
testcase_18 AC 38 ms
10,448 KB
testcase_19 WA -
testcase_20 AC 38 ms
10,428 KB
testcase_21 WA -
testcase_22 AC 41 ms
10,344 KB
testcase_23 WA -
testcase_24 AC 41 ms
10,484 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 41 ms
10,500 KB
testcase_30 AC 96 ms
10,468 KB
testcase_31 AC 109 ms
10,492 KB
testcase_32 AC 190 ms
10,480 KB
testcase_33 RE -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 838 ms
10,544 KB
testcase_38 AC 797 ms
10,520 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]%mod
print(ans)
0