結果
問題 | No.1417 100の倍数かつ正整数(2) |
ユーザー | wolgnik |
提出日時 | 2021-03-05 22:03:55 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 157 ms / 3,000 ms |
コード長 | 2,056 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 82,580 KB |
実行使用メモリ | 80,636 KB |
最終ジャッジ日時 | 2024-04-16 09:32:41 |
合計ジャッジ時間 | 3,853 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
53,120 KB |
testcase_01 | AC | 41 ms
52,608 KB |
testcase_02 | AC | 58 ms
67,328 KB |
testcase_03 | AC | 35 ms
52,992 KB |
testcase_04 | AC | 38 ms
52,736 KB |
testcase_05 | AC | 38 ms
52,992 KB |
testcase_06 | AC | 38 ms
52,992 KB |
testcase_07 | AC | 36 ms
52,992 KB |
testcase_08 | AC | 36 ms
52,992 KB |
testcase_09 | AC | 39 ms
52,736 KB |
testcase_10 | AC | 36 ms
52,864 KB |
testcase_11 | AC | 37 ms
53,120 KB |
testcase_12 | AC | 44 ms
60,800 KB |
testcase_13 | AC | 44 ms
61,440 KB |
testcase_14 | AC | 49 ms
62,976 KB |
testcase_15 | AC | 54 ms
65,536 KB |
testcase_16 | AC | 58 ms
67,840 KB |
testcase_17 | AC | 59 ms
68,352 KB |
testcase_18 | AC | 75 ms
74,536 KB |
testcase_19 | AC | 65 ms
71,936 KB |
testcase_20 | AC | 72 ms
74,112 KB |
testcase_21 | AC | 68 ms
73,600 KB |
testcase_22 | AC | 68 ms
73,472 KB |
testcase_23 | AC | 71 ms
74,112 KB |
testcase_24 | AC | 60 ms
67,892 KB |
testcase_25 | AC | 71 ms
74,368 KB |
testcase_26 | AC | 71 ms
73,600 KB |
testcase_27 | AC | 69 ms
72,192 KB |
testcase_28 | AC | 75 ms
75,168 KB |
testcase_29 | AC | 83 ms
76,516 KB |
testcase_30 | AC | 92 ms
76,784 KB |
testcase_31 | AC | 65 ms
71,040 KB |
testcase_32 | AC | 124 ms
78,200 KB |
testcase_33 | AC | 102 ms
78,208 KB |
testcase_34 | AC | 157 ms
80,280 KB |
testcase_35 | AC | 146 ms
80,604 KB |
testcase_36 | AC | 148 ms
80,636 KB |
testcase_37 | AC | 121 ms
79,656 KB |
testcase_38 | AC | 90 ms
79,360 KB |
ソースコード
import sys input = sys.stdin.readline S = list(map(int, list(input())[: -1])) mod = 10 ** 9 + 7 ln = len(S) dp = [[0] * 9 for _ in range(ln + 1)] dp[1][0] = 1 dplim = [[0] * 9 for _ in range(ln + 1)] dplim[0][0] = 1 for i in range(ln): x = S[i] if i + 1 >= 2: dp[i + 1][0] += 1 for two in range(3): for five in range(3): j = two * 3 + five if x: if x % 2 == 0 and x % 4 != 0: dplim[i + 1][min(2, two + 1) * 3 + five] += dplim[i][j] dplim[i + 1][min(2, two + 1) * 3 + five] %= mod elif x % 4 == 0: dplim[i + 1][min(2, two + 2) * 3 + five] += dplim[i][j] dplim[i + 1][min(2, two + 2) * 3 + five] %= mod elif x % 5 == 0: dplim[i + 1][two * 3 + min(2, five + 1)] += dplim[i][j] dplim[i + 1][two * 3 + min(2, five + 1)] %= mod else: dplim[i + 1][j] += dplim[i][j] dplim[i + 1][j] %= mod for k in range(1, x): if k % 2 == 0 and k % 4 != 0: dp[i + 1][min(2, two + 1) * 3 + five] += dplim[i][j] dp[i + 1][min(2, two + 1) * 3 + five] %= mod elif k % 4 == 0: dp[i + 1][min(2, two + 2) * 3 + five] += dplim[i][j] dp[i + 1][min(2, two + 2) * 3 + five] %= mod elif k % 5 == 0: dp[i + 1][two * 3 + min(2, five + 1)] += dplim[i][j] dp[i + 1][two * 3 + min(2, five + 1)] %= mod else: dp[i + 1][j] += dplim[i][j] dp[i + 1][j] %= mod for k in range(1, 10): if k % 2 == 0 and k % 4 != 0: dp[i + 1][min(2, two + 1) * 3 + five] += dp[i][j] dp[i + 1][min(2, two + 1) * 3 + five] %= mod elif k % 4 == 0: dp[i + 1][min(2, two + 2) * 3 + five] += dp[i][j] dp[i + 1][min(2, two + 2) * 3 + five] %= mod elif k % 5 == 0: dp[i + 1][two * 3 + min(2, five + 1)] += dp[i][j] dp[i + 1][two * 3 + min(2, five + 1)] %= mod else: dp[i + 1][j] += dp[i][j] dp[i + 1][j] %= mod print((dp[-1][-1] + dplim[-1][-1]) % mod)