結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー tktk_snsntktk_snsn
提出日時 2021-03-14 19:06:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 463 ms / 3,000 ms
コード長 1,354 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 82,128 KB
実行使用メモリ 103,512 KB
最終ジャッジ日時 2024-04-24 01:48:10
合計ジャッジ時間 7,542 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
61,796 KB
testcase_01 AC 53 ms
64,192 KB
testcase_02 AC 122 ms
77,472 KB
testcase_03 AC 42 ms
58,324 KB
testcase_04 AC 43 ms
58,444 KB
testcase_05 AC 47 ms
60,436 KB
testcase_06 AC 47 ms
60,696 KB
testcase_07 AC 49 ms
62,304 KB
testcase_08 AC 48 ms
61,072 KB
testcase_09 AC 48 ms
61,264 KB
testcase_10 AC 51 ms
62,784 KB
testcase_11 AC 50 ms
62,796 KB
testcase_12 AC 83 ms
75,988 KB
testcase_13 AC 87 ms
76,580 KB
testcase_14 AC 98 ms
76,500 KB
testcase_15 AC 115 ms
77,220 KB
testcase_16 AC 117 ms
77,512 KB
testcase_17 AC 119 ms
77,292 KB
testcase_18 AC 142 ms
77,992 KB
testcase_19 AC 140 ms
77,536 KB
testcase_20 AC 146 ms
77,920 KB
testcase_21 AC 153 ms
77,688 KB
testcase_22 AC 155 ms
77,824 KB
testcase_23 AC 157 ms
78,608 KB
testcase_24 AC 131 ms
77,860 KB
testcase_25 AC 156 ms
77,776 KB
testcase_26 AC 154 ms
77,944 KB
testcase_27 AC 160 ms
78,536 KB
testcase_28 AC 158 ms
77,536 KB
testcase_29 AC 154 ms
78,248 KB
testcase_30 AC 187 ms
80,288 KB
testcase_31 AC 165 ms
79,888 KB
testcase_32 AC 293 ms
84,116 KB
testcase_33 AC 282 ms
90,436 KB
testcase_34 AC 439 ms
102,684 KB
testcase_35 AC 450 ms
103,392 KB
testcase_36 AC 463 ms
103,508 KB
testcase_37 AC 452 ms
103,512 KB
testcase_38 AC 351 ms
102,692 KB
権限があれば一括ダウンロードができます

ソースコード

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