結果
問題 | No.6 使いものにならないハッシュ |
ユーザー | mkawa2 |
提出日時 | 2019-12-30 21:33:04 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 76 ms / 5,000 ms |
コード長 | 1,351 bytes |
コンパイル時間 | 111 ms |
コンパイル使用メモリ | 10,936 KB |
実行使用メモリ | 11,424 KB |
最終ジャッジ日時 | 2023-10-14 23:21:07 |
合計ジャッジ時間 | 2,972 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
9,548 KB |
testcase_01 | AC | 30 ms
9,524 KB |
testcase_02 | AC | 76 ms
11,424 KB |
testcase_03 | AC | 35 ms
10,132 KB |
testcase_04 | AC | 37 ms
10,276 KB |
testcase_05 | AC | 42 ms
10,392 KB |
testcase_06 | AC | 51 ms
10,492 KB |
testcase_07 | AC | 39 ms
10,132 KB |
testcase_08 | AC | 47 ms
10,424 KB |
testcase_09 | AC | 34 ms
9,860 KB |
testcase_10 | AC | 28 ms
9,588 KB |
testcase_11 | AC | 37 ms
10,164 KB |
testcase_12 | AC | 60 ms
11,112 KB |
testcase_13 | AC | 31 ms
9,900 KB |
testcase_14 | AC | 34 ms
9,804 KB |
testcase_15 | AC | 52 ms
10,532 KB |
testcase_16 | AC | 40 ms
10,324 KB |
testcase_17 | AC | 59 ms
11,196 KB |
testcase_18 | AC | 70 ms
11,276 KB |
testcase_19 | AC | 57 ms
11,252 KB |
testcase_20 | AC | 57 ms
10,816 KB |
testcase_21 | AC | 32 ms
9,792 KB |
testcase_22 | AC | 56 ms
10,688 KB |
testcase_23 | AC | 57 ms
11,148 KB |
testcase_24 | AC | 56 ms
10,764 KB |
testcase_25 | AC | 42 ms
10,424 KB |
testcase_26 | AC | 63 ms
11,116 KB |
testcase_27 | AC | 52 ms
10,360 KB |
testcase_28 | AC | 44 ms
10,524 KB |
testcase_29 | AC | 65 ms
11,116 KB |
testcase_30 | AC | 62 ms
11,340 KB |
testcase_31 | AC | 56 ms
11,188 KB |
ソースコード
import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def main(): def hash(x): if x < 10: return x if x in memo: return memo[x] res = memo[x] = hash(sum(int(c) for c in str(x))) return res memo = {} k = II() n = II() prime = [0, 1] * 100005 prime[1] = 0 prime[2] = 1 for x in range(3, 200005): if x ** 2 > 200005: break if prime[x]: for y in range(x ** 2, 200005, x): prime[y] = 0 xx = [] hh = [] for x in range(k, n + 1): if prime[x]: h = hash(x) xx.append(x) hh.append(h) #print(xx) #print(hh) mx_len = 0 ans_x = 0 last_pos = [-1] * 10 l = 0 for r, h in enumerate(hh): if last_pos[h] >= l: length = r - last_pos[h] l = last_pos[h] + 1 else: length = r - l + 1 if length >= mx_len: mx_len = length ans_x = xx[r - length + 1] last_pos[h] = r #print(mx_len) print(ans_x) main()