結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー 👑 H20H20
提出日時 2021-02-20 02:25:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 899 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 11,824 KB
実行使用メモリ 10,396 KB
最終ジャッジ日時 2023-10-25 04:55:38
合計ジャッジ時間 19,632 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,176 KB
testcase_01 AC 34 ms
10,096 KB
testcase_02 AC 1,193 ms
10,384 KB
testcase_03 AC 29 ms
10,092 KB
testcase_04 AC 29 ms
10,092 KB
testcase_05 AC 31 ms
10,092 KB
testcase_06 AC 31 ms
10,092 KB
testcase_07 AC 31 ms
10,092 KB
testcase_08 AC 32 ms
10,092 KB
testcase_09 AC 31 ms
10,092 KB
testcase_10 AC 32 ms
10,092 KB
testcase_11 AC 33 ms
10,096 KB
testcase_12 AC 76 ms
10,132 KB
testcase_13 AC 85 ms
10,148 KB
testcase_14 AC 161 ms
10,172 KB
testcase_15 AC 242 ms
10,204 KB
testcase_16 AC 285 ms
10,208 KB
testcase_17 AC 314 ms
10,228 KB
testcase_18 AC 513 ms
10,272 KB
testcase_19 AC 575 ms
10,280 KB
testcase_20 AC 608 ms
10,288 KB
testcase_21 AC 957 ms
10,360 KB
testcase_22 AC 1,063 ms
10,376 KB
testcase_23 AC 1,104 ms
10,380 KB
testcase_24 AC 1,118 ms
10,376 KB
testcase_25 AC 1,125 ms
10,392 KB
testcase_26 AC 1,146 ms
10,392 KB
testcase_27 AC 1,174 ms
10,396 KB
testcase_28 AC 1,172 ms
10,396 KB
testcase_29 AC 1,175 ms
10,396 KB
testcase_30 TLE -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product

N = input()
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