結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー chineristACchineristAC
提出日時 2021-03-05 22:03:25
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,831 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 228,280 KB
最終ジャッジ日時 2024-04-16 09:32:34
合計ジャッジ時間 20,139 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
62,976 KB
testcase_01 AC 65 ms
63,232 KB
testcase_02 AC 117 ms
77,772 KB
testcase_03 AC 59 ms
62,592 KB
testcase_04 AC 60 ms
62,592 KB
testcase_05 AC 59 ms
63,104 KB
testcase_06 AC 59 ms
62,848 KB
testcase_07 AC 60 ms
62,976 KB
testcase_08 AC 61 ms
62,976 KB
testcase_09 AC 60 ms
62,976 KB
testcase_10 AC 60 ms
62,976 KB
testcase_11 AC 60 ms
63,232 KB
testcase_12 AC 82 ms
71,168 KB
testcase_13 AC 80 ms
70,784 KB
testcase_14 AC 91 ms
73,856 KB
testcase_15 AC 106 ms
77,568 KB
testcase_16 AC 108 ms
77,312 KB
testcase_17 AC 107 ms
77,440 KB
testcase_18 AC 113 ms
77,440 KB
testcase_19 AC 115 ms
77,952 KB
testcase_20 AC 113 ms
77,824 KB
testcase_21 AC 127 ms
78,464 KB
testcase_22 AC 122 ms
77,696 KB
testcase_23 AC 132 ms
78,336 KB
testcase_24 AC 115 ms
77,696 KB
testcase_25 AC 126 ms
78,592 KB
testcase_26 AC 131 ms
78,592 KB
testcase_27 AC 124 ms
78,336 KB
testcase_28 AC 127 ms
78,592 KB
testcase_29 AC 122 ms
77,824 KB
testcase_30 AC 197 ms
79,936 KB
testcase_31 AC 155 ms
79,792 KB
testcase_32 AC 415 ms
85,564 KB
testcase_33 AC 749 ms
117,832 KB
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def cmb(n, r, mod):#コンビネーションの高速計算 
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] % mod) * g2[n-r] % mod

mod = 998244353#出力の制限
N = 2*10**3
g1 = [1]*(N+1) # 元テーブル
g2 = [1]*(N+1) #逆元テーブル
inverse = [1]*(N+1) #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1[i]=( ( g1[i-1] * i ) % mod )
    inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2[i]=( (g2[i-1] * inverse[i]) % mod )
inverse[0]=0

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

N = input()
n = len(N)
mod = 10**9 + 7

r = [1,2,4,5,10,20,25,50,100]
cond = {r:i for i,r in enumerate(r)}
def conv(i):
    cnt_2,cnt_5 = 0,0
    while i and i%2==0:
        cnt_2 += 1
        i //= 2
    while i and i%5==0:
        cnt_5 += 1
        i //= 5
    cnt_2,cnt_5 = min(cnt_2,2),min(cnt_5,2)
    return cond[2**cnt_2 * 5**cnt_5]


dp = [[[0 for i in range(9)] for bit in range(2)] for i in range(n)]
for i in range(1,10):
    c = conv(i)
    dp[0][1][c] += 1
    if i<=int(N[-1]):
        dp[0][0][c] += 1

res = 0
for i in range(n):
    s = int(N[-i-1])
    for j in range(9):
        a = r[j]
        for k in range(1,10):
            next = conv(a*k)
            if s>k:
                dp[i][0][next] += dp[i-1][1][j]
            elif s==k:
                dp[i][0][next] += dp[i-1][0][j]
            dp[i][0][next] %= mod

            dp[i][1][next] += dp[i-1][1][j]
            dp[i][0][next] %= mod

    if i!=n-1:
        res += dp[i][1][8]
    else:
        res += dp[i][0][8]
    res %= mod

print(res)
0