結果

問題 No.6 使いものにならないハッシュ
ユーザー square1001square1001
提出日時 2022-02-17 10:51:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 146 ms / 5,000 ms
コード長 514 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 10,784 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2023-09-11 17:29:35
合計ジャッジ時間 4,440 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,820 KB
testcase_01 AC 17 ms
7,780 KB
testcase_02 AC 146 ms
10,100 KB
testcase_03 AC 37 ms
8,432 KB
testcase_04 AC 53 ms
8,616 KB
testcase_05 AC 54 ms
8,756 KB
testcase_06 AC 93 ms
9,252 KB
testcase_07 AC 79 ms
9,268 KB
testcase_08 AC 91 ms
9,320 KB
testcase_09 AC 95 ms
9,516 KB
testcase_10 AC 15 ms
7,816 KB
testcase_11 AC 39 ms
8,444 KB
testcase_12 AC 101 ms
9,736 KB
testcase_13 AC 87 ms
9,408 KB
testcase_14 AC 91 ms
9,588 KB
testcase_15 AC 88 ms
9,180 KB
testcase_16 AC 95 ms
9,784 KB
testcase_17 AC 124 ms
10,240 KB
testcase_18 AC 139 ms
10,112 KB
testcase_19 AC 119 ms
9,676 KB
testcase_20 AC 104 ms
9,488 KB
testcase_21 AC 28 ms
8,188 KB
testcase_22 AC 112 ms
9,672 KB
testcase_23 AC 100 ms
9,416 KB
testcase_24 AC 110 ms
9,596 KB
testcase_25 AC 83 ms
9,236 KB
testcase_26 AC 124 ms
9,964 KB
testcase_27 AC 107 ms
9,540 KB
testcase_28 AC 70 ms
8,948 KB
testcase_29 AC 129 ms
9,996 KB
testcase_30 AC 116 ms
9,796 KB
testcase_31 AC 110 ms
9,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

L = int(input())
R = int(input())

prime = [ True ] * (R + 1)
prime[0], prime[1] = False, False
for i in range(2, R + 1):
	if prime[i]:
		for j in range(i * 2, R + 1, i):
			prime[j] = False

maxlen = 0
answer = -1
plist = list(filter(lambda x: prime[x], range(L, R + 1)))
for i in range(len(plist)):
	bit = 0
	pos = i
	while pos < len(plist):
		if ((bit >> (plist[pos] % 9)) & 1) == 1:
			break
		bit |= 1 << (plist[pos] % 9)
		pos += 1
	if maxlen <= pos - i:
		maxlen = pos - i
		answer = plist[i]

print(answer)
0