結果
問題 | No.260 世界のなんとか3 |
ユーザー | tomatonosuke |
提出日時 | 2017-04-05 00:41:34 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 2,181 bytes |
コンパイル時間 | 208 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 89,036 KB |
最終ジャッジ日時 | 2024-07-08 09:12:00 |
合計ジャッジ時間 | 3,714 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
60,928 KB |
testcase_01 | MLE | - |
testcase_02 | MLE | - |
testcase_03 | MLE | - |
testcase_04 | MLE | - |
testcase_05 | MLE | - |
testcase_06 | MLE | - |
testcase_07 | MLE | - |
testcase_08 | MLE | - |
testcase_09 | MLE | - |
testcase_10 | MLE | - |
testcase_11 | MLE | - |
testcase_12 | MLE | - |
testcase_13 | MLE | - |
testcase_14 | MLE | - |
testcase_15 | MLE | - |
testcase_16 | MLE | - |
testcase_17 | MLE | - |
testcase_18 | MLE | - |
testcase_19 | MLE | - |
testcase_20 | MLE | - |
testcase_21 | MLE | - |
testcase_22 | MLE | - |
testcase_23 | MLE | - |
testcase_24 | MLE | - |
testcase_25 | MLE | - |
testcase_26 | MLE | - |
testcase_27 | AC | 36 ms
52,992 KB |
testcase_28 | MLE | - |
testcase_29 | MLE | - |
ソースコード
minnum,maxnum = (n for n in input().split(" ")) minnum = str(int(minnum)) maxnum = str(int(maxnum) + 1) min_len = len(minnum) max_len = len(maxnum) modu = 10 ** 9 + 7 maxdp = [[[[[0 for n in range(8)] for m in range(3)] for k in range(2)] for l in range(2)] for o in range(max_len + 1)] mindp = [[[[[0 for n in range(8)] for m in range(3)] for k in range(2)] for l in range(2)] for o in range(min_len + 1)] maxdp[0][0][0][0][0] = 1 mindp[0][0][0][0][0] = 1 for l in range(max_len): for over_flag in range(2): for is_three in range(2): for three_mod in range(3): for eight_mod in range(8): limit = 9 if over_flag else int(maxnum[l]) for lim in range(limit + 1): maxdp[l + 1][over_flag or lim < limit][is_three or lim == 3][(three_mod * 10 + lim) % 3][(eight_mod * 10 + lim) % 8] += (maxdp[l][over_flag][is_three][three_mod][eight_mod]) % modu for l in range(min_len): for over_flag in range(2): for is_three in range(2): for three_mod in range(3): for eight_mod in range(8): limit = 9 if over_flag else int(minnum[l]) for lim in range(limit + 1): mindp[l + 1][over_flag or lim < limit][is_three or lim == 3][(three_mod * 10 + lim) % 3][(eight_mod * 10 + lim) % 8] += (mindp[l][over_flag][is_three][three_mod][eight_mod]) % modu max_number = 0 min_number = 0 for over_flag in range(2): for is_three in range(2): for three_mod in range(3): for eight_mod in range(1,8): if over_flag and (is_three or three_mod == 0): min_number = (min_number + mindp[min_len][over_flag][is_three][three_mod][eight_mod]) % modu for over_flag in range(2): for is_three in range(2): for three_mod in range(3): for eight_mod in range(1,8): if over_flag and (is_three or three_mod == 0): max_number = (max_number + maxdp[max_len][over_flag][is_three][three_mod][eight_mod]) % modu # print(maxdp , mindp) # print(max_number , min_number) print((max_number - min_number) % modu)