結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー 👑 H20H20
提出日時 2021-02-20 03:24:39
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 955 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 81,404 KB
実行使用メモリ 273,660 KB
最終ジャッジ日時 2023-10-25 04:56:12
合計ジャッジ時間 16,731 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
68,232 KB
testcase_01 AC 71 ms
70,252 KB
testcase_02 AC 800 ms
86,128 KB
testcase_03 AC 38 ms
53,224 KB
testcase_04 AC 45 ms
59,516 KB
testcase_05 AC 48 ms
61,336 KB
testcase_06 AC 49 ms
61,352 KB
testcase_07 AC 48 ms
61,800 KB
testcase_08 AC 53 ms
63,444 KB
testcase_09 AC 53 ms
63,448 KB
testcase_10 AC 54 ms
63,916 KB
testcase_11 AC 60 ms
68,064 KB
testcase_12 AC 212 ms
77,872 KB
testcase_13 AC 223 ms
78,472 KB
testcase_14 AC 430 ms
81,564 KB
testcase_15 AC 382 ms
80,676 KB
testcase_16 AC 457 ms
81,260 KB
testcase_17 AC 419 ms
81,900 KB
testcase_18 AC 498 ms
82,676 KB
testcase_19 AC 505 ms
82,908 KB
testcase_20 AC 538 ms
82,724 KB
testcase_21 AC 612 ms
84,520 KB
testcase_22 AC 637 ms
84,348 KB
testcase_23 AC 651 ms
85,104 KB
testcase_24 AC 755 ms
86,352 KB
testcase_25 AC 654 ms
84,864 KB
testcase_26 AC 656 ms
85,068 KB
testcase_27 AC 659 ms
84,732 KB
testcase_28 AC 645 ms
84,972 KB
testcase_29 AC 672 ms
85,348 KB
testcase_30 TLE -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#assert
from itertools import product

N = input()
if not(1<=int(N)<=10**100):
    print('error')

mod=10**9+7

def count(a):
    n = len(a)
    dp=[[[[[0] * 2 for i in range(3)] for j in range(3)] for k in range(2)] for l in range(n+1)]
    dp[0][0][0][0][0] = 1

    for i, less, divcnt5, divcnt2, has0 in product(range(n), (0,1), range(3), range(3), (0,1)):
        max_d = 9 if less else int(a[i])
        for d in range(max_d+1):
            less_ = less or d < max_d
            divcnt5_ = min(2,divcnt5+(d==5))
            if d==4 or d==8:
                divcnt2_=2
            elif d==2 or d==6:
                divcnt2_=min(2,divcnt2+1)
            else:
                divcnt2_ = divcnt2
            has0_ = has0 or d==0
            dp[i + 1][less_][divcnt5_][divcnt2_][has0_] += dp[i][less][divcnt5][divcnt2][has0]

    return dp[n][0][2][2][0]+dp[n][1][2][2][0]

ans = count(N)
for i in range(len(N)):
    ans += count('9'*i)
print(ans%mod)
0