結果
| 問題 |
No.1417 100の倍数かつ正整数(2)
|
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2023-02-02 05:11:07 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,449 bytes |
| コンパイル時間 | 278 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-07-01 21:11:04 |
| 合計ジャッジ時間 | 7,549 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 9 RE * 2 |
ソースコード
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)
vwxyz