結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー tktk_snsntktk_snsn
提出日時 2021-03-14 19:05:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,361 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 46,240 KB
最終ジャッジ日時 2024-04-24 01:47:17
合計ジャッジ時間 10,583 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
16,384 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 66 ms
11,136 KB
testcase_03 AC 30 ms
11,008 KB
testcase_04 AC 28 ms
10,880 KB
testcase_05 AC 28 ms
10,880 KB
testcase_06 AC 29 ms
10,752 KB
testcase_07 AC 29 ms
10,880 KB
testcase_08 AC 29 ms
10,880 KB
testcase_09 AC 28 ms
11,008 KB
testcase_10 AC 31 ms
11,008 KB
testcase_11 AC 31 ms
10,880 KB
testcase_12 AC 38 ms
10,880 KB
testcase_13 AC 39 ms
10,880 KB
testcase_14 AC 41 ms
10,880 KB
testcase_15 AC 45 ms
11,008 KB
testcase_16 AC 46 ms
11,008 KB
testcase_17 AC 49 ms
11,008 KB
testcase_18 AC 56 ms
11,008 KB
testcase_19 AC 54 ms
11,008 KB
testcase_20 AC 60 ms
11,008 KB
testcase_21 AC 66 ms
11,136 KB
testcase_22 AC 69 ms
11,008 KB
testcase_23 AC 71 ms
11,136 KB
testcase_24 AC 69 ms
11,008 KB
testcase_25 AC 73 ms
11,136 KB
testcase_26 AC 72 ms
11,264 KB
testcase_27 AC 72 ms
11,136 KB
testcase_28 AC 73 ms
11,136 KB
testcase_29 AC 77 ms
11,264 KB
testcase_30 AC 392 ms
12,928 KB
testcase_31 AC 421 ms
13,696 KB
testcase_32 AC 904 ms
16,640 KB
testcase_33 AC 2,109 ms
25,344 KB
testcase_34 TLE -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [[[[[0]*2 for _ in range(2)] for _ in range(3)]
       for _ in range(3)] for _ in range(N + 1)]
dp[0][0][0][0][0] = 1
for i, s in enumerate(S):
    nd = int(s)
    for j in range(3):
        for k in range(3):
            for l in range(2):
                for m in range(2):
                    for d in range(10):
                        ni = i + 1
                        nj = j
                        nk = k
                        nl = l
                        nm = m
                        if d == 0 and nm == 1:
                            continue
                        if d != 0:
                            nm = 1
                        if d in (2, 6):
                            nj = min(nj + 1, 2)
                        if d in (4, 8):
                            nj = min(nj + 2, 2)
                        if d == 5:
                            nk = min(nk + 1, 2)
                        if nl == 0:
                            if d > nd:
                                continue
                            if d < nd:
                                nl = 1
                        dp[ni][nj][nk][nl][nm] += dp[i][j][k][l][m]
                        dp[ni][nj][nk][nl][nm] %= mod

ans = 0
for i in range(2):
    for j in range(2):
        ans += dp[N][2][2][i][j]
        ans %= mod
print(ans)
0