結果
問題 | No.1417 100の倍数かつ正整数(2) |
ユーザー | marroncastle |
提出日時 | 2021-03-15 12:03:57 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 241 ms / 3,000 ms |
コード長 | 1,256 bytes |
コンパイル時間 | 202 ms |
コンパイル使用メモリ | 81,720 KB |
実行使用メモリ | 78,220 KB |
最終ジャッジ日時 | 2024-11-07 00:41:20 |
合計ジャッジ時間 | 5,427 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
52,992 KB |
testcase_01 | AC | 41 ms
53,120 KB |
testcase_02 | AC | 86 ms
76,128 KB |
testcase_03 | AC | 40 ms
52,480 KB |
testcase_04 | AC | 41 ms
52,608 KB |
testcase_05 | AC | 40 ms
52,424 KB |
testcase_06 | AC | 40 ms
52,224 KB |
testcase_07 | AC | 40 ms
52,736 KB |
testcase_08 | AC | 40 ms
52,948 KB |
testcase_09 | AC | 41 ms
52,480 KB |
testcase_10 | AC | 40 ms
52,736 KB |
testcase_11 | AC | 41 ms
53,120 KB |
testcase_12 | AC | 54 ms
63,232 KB |
testcase_13 | AC | 55 ms
64,128 KB |
testcase_14 | AC | 64 ms
68,096 KB |
testcase_15 | AC | 76 ms
74,368 KB |
testcase_16 | AC | 86 ms
76,160 KB |
testcase_17 | AC | 87 ms
76,004 KB |
testcase_18 | AC | 101 ms
76,672 KB |
testcase_19 | AC | 96 ms
76,224 KB |
testcase_20 | AC | 102 ms
76,140 KB |
testcase_21 | AC | 100 ms
76,124 KB |
testcase_22 | AC | 105 ms
76,028 KB |
testcase_23 | AC | 102 ms
76,100 KB |
testcase_24 | AC | 90 ms
76,076 KB |
testcase_25 | AC | 105 ms
76,220 KB |
testcase_26 | AC | 100 ms
76,176 KB |
testcase_27 | AC | 102 ms
76,228 KB |
testcase_28 | AC | 103 ms
76,196 KB |
testcase_29 | AC | 103 ms
76,216 KB |
testcase_30 | AC | 145 ms
77,312 KB |
testcase_31 | AC | 115 ms
76,808 KB |
testcase_32 | AC | 160 ms
77,324 KB |
testcase_33 | AC | 177 ms
77,628 KB |
testcase_34 | AC | 225 ms
77,564 KB |
testcase_35 | AC | 228 ms
77,520 KB |
testcase_36 | AC | 227 ms
78,220 KB |
testcase_37 | AC | 241 ms
77,568 KB |
testcase_38 | AC | 173 ms
76,480 KB |
ソースコード
N = list(map(int,list(input()))) digit = len(N) MOD = 10**9+7 twos = [0,0,1,0,2,0,1,0,3,0] fives = [0,0,0,0,0,1,0,0,0,0] dp = [[[0]*3 for _ in range(3)] for _ in range(2)] dp[1][0][0] = 1 for i in range(digit): new_dp = [[[0]*3 for _ in range(3)] for _ in range(2)] if N[i]>0: for two in range(3): for five in range(3): new_dp[1][min(2,two+twos[N[i]])][min(2,five+fives[N[i]])] += dp[1][two][five] new_dp[1][two][five] %= MOD for k in range(1,N[i]): for two in range(3): for five in range(3): new_dp[0][min(2,two+twos[k])][min(2,five+fives[k])] += dp[1][two][five] new_dp[0][two][five] %= MOD for k in range(1,10): for two in range(3): for five in range(3): new_dp[0][min(2,two+twos[k])][min(2,five+fives[k])] += dp[0][two][five] new_dp[0][two][five] %= MOD dp = new_dp ans = dp[0][2][2] + dp[1][2][2] dp2 = [[0]*3 for _ in range(3)] dp2[0][0] = 1 for i in range(digit-1): new_dp2 = [[0]*3 for _ in range(3)] for k in range(1,10): for two in range(3): for five in range(3): new_dp2[min(2,two+twos[k])][min(2,five+fives[k])] += dp2[two][five] new_dp2[two][five] %= MOD dp2 = new_dp2 ans += dp2[2][2] ans %= MOD print(ans)