結果

問題 No.6 使いものにならないハッシュ
ユーザー dangodango
提出日時 2023-06-19 16:58:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 5,000 ms
コード長 492 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 79,116 KB
最終ジャッジ日時 2023-09-09 12:20:30
合計ジャッジ時間 5,089 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,424 KB
testcase_01 AC 73 ms
71,056 KB
testcase_02 AC 121 ms
79,116 KB
testcase_03 AC 95 ms
76,920 KB
testcase_04 AC 97 ms
77,100 KB
testcase_05 AC 98 ms
77,120 KB
testcase_06 AC 99 ms
77,644 KB
testcase_07 AC 94 ms
77,848 KB
testcase_08 AC 105 ms
77,800 KB
testcase_09 AC 101 ms
78,180 KB
testcase_10 AC 76 ms
71,180 KB
testcase_11 AC 98 ms
77,204 KB
testcase_12 AC 100 ms
77,932 KB
testcase_13 AC 100 ms
78,232 KB
testcase_14 AC 101 ms
78,312 KB
testcase_15 AC 102 ms
77,804 KB
testcase_16 AC 101 ms
78,180 KB
testcase_17 AC 103 ms
78,220 KB
testcase_18 AC 111 ms
78,812 KB
testcase_19 AC 100 ms
78,312 KB
testcase_20 AC 102 ms
77,848 KB
testcase_21 AC 94 ms
77,012 KB
testcase_22 AC 104 ms
78,032 KB
testcase_23 AC 100 ms
77,872 KB
testcase_24 AC 104 ms
78,000 KB
testcase_25 AC 99 ms
77,820 KB
testcase_26 AC 107 ms
79,100 KB
testcase_27 AC 102 ms
78,268 KB
testcase_28 AC 96 ms
77,444 KB
testcase_29 AC 109 ms
78,920 KB
testcase_30 AC 101 ms
78,020 KB
testcase_31 AC 102 ms
77,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

K = int(input())
N = int(input())
prime = [True] * (N + 1)
prime[0], prime[1] = False, False
for i in range(2, N + 1):
	if prime[i]:
		for j in range(i * 2, N + 1, i):
			prime[j] = False
ML = 0
ans = -1
primelist = list(filter(lambda x: prime[x], range(K, N + 1)))
for i in range(len(primelist)):
	B = 0
	P = i
	while P < len(primelist):
		if ((B >> (primelist[P] % 9)) & 1) == 1:
			break
		B |= 1 << (primelist[P] % 9)
		P += 1
	if ML <= P - i:
		ML = P - i
		ans = primelist[i]
print(ans)
0