結果
問題 | No.260 世界のなんとか3 |
ユーザー | tomatonosuke |
提出日時 | 2017-04-05 00:41:19 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,181 bytes |
コンパイル時間 | 78 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 33,664 KB |
最終ジャッジ日時 | 2024-07-08 09:10:51 |
合計ジャッジ時間 | 11,068 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
10,880 KB |
testcase_01 | AC | 30 ms
10,880 KB |
testcase_02 | AC | 32 ms
11,008 KB |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | AC | 1,959 ms
27,392 KB |
testcase_06 | AC | 1,340 ms
21,888 KB |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | TLE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | AC | 1,209 ms
21,504 KB |
testcase_14 | RE | - |
testcase_15 | AC | 1,701 ms
25,728 KB |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | AC | 587 ms
15,872 KB |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | AC | 27 ms
10,752 KB |
testcase_28 | RE | - |
testcase_29 | RE | - |
ソースコード
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)