結果
問題 | No.1417 100の倍数かつ正整数(2) |
ユーザー | wolgnik |
提出日時 | 2021-03-05 22:03:55 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 155 ms / 3,000 ms |
コード長 | 2,056 bytes |
コンパイル時間 | 279 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 80,472 KB |
最終ジャッジ日時 | 2024-10-07 01:58:51 |
合計ジャッジ時間 | 4,122 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
52,224 KB |
testcase_01 | AC | 39 ms
52,736 KB |
testcase_02 | AC | 70 ms
67,200 KB |
testcase_03 | AC | 40 ms
52,608 KB |
testcase_04 | AC | 39 ms
52,480 KB |
testcase_05 | AC | 38 ms
52,224 KB |
testcase_06 | AC | 39 ms
52,608 KB |
testcase_07 | AC | 39 ms
52,864 KB |
testcase_08 | AC | 38 ms
52,736 KB |
testcase_09 | AC | 42 ms
52,352 KB |
testcase_10 | AC | 39 ms
52,608 KB |
testcase_11 | AC | 38 ms
52,480 KB |
testcase_12 | AC | 46 ms
60,288 KB |
testcase_13 | AC | 49 ms
60,928 KB |
testcase_14 | AC | 53 ms
62,464 KB |
testcase_15 | AC | 59 ms
65,536 KB |
testcase_16 | AC | 64 ms
67,968 KB |
testcase_17 | AC | 67 ms
68,096 KB |
testcase_18 | AC | 81 ms
74,496 KB |
testcase_19 | AC | 76 ms
71,936 KB |
testcase_20 | AC | 81 ms
74,496 KB |
testcase_21 | AC | 81 ms
73,600 KB |
testcase_22 | AC | 79 ms
73,472 KB |
testcase_23 | AC | 80 ms
74,112 KB |
testcase_24 | AC | 69 ms
67,712 KB |
testcase_25 | AC | 83 ms
73,984 KB |
testcase_26 | AC | 83 ms
73,728 KB |
testcase_27 | AC | 76 ms
71,936 KB |
testcase_28 | AC | 84 ms
75,008 KB |
testcase_29 | AC | 90 ms
76,416 KB |
testcase_30 | AC | 100 ms
76,544 KB |
testcase_31 | AC | 74 ms
70,912 KB |
testcase_32 | AC | 125 ms
78,064 KB |
testcase_33 | AC | 113 ms
78,208 KB |
testcase_34 | AC | 152 ms
80,276 KB |
testcase_35 | AC | 150 ms
80,472 KB |
testcase_36 | AC | 155 ms
80,256 KB |
testcase_37 | AC | 127 ms
79,712 KB |
testcase_38 | AC | 98 ms
79,616 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)