結果

問題 No.6 使いものにならないハッシュ
ユーザー dangodango
提出日時 2023-06-19 16:58:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 80 ms / 5,000 ms
コード長 492 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 74,624 KB
最終ジャッジ日時 2024-06-27 05:25:08
合計ジャッジ時間 3,721 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
51,712 KB
testcase_01 AC 40 ms
52,096 KB
testcase_02 AC 80 ms
74,624 KB
testcase_03 AC 63 ms
65,792 KB
testcase_04 AC 65 ms
67,456 KB
testcase_05 AC 72 ms
69,632 KB
testcase_06 AC 73 ms
71,040 KB
testcase_07 AC 66 ms
68,096 KB
testcase_08 AC 71 ms
70,400 KB
testcase_09 AC 68 ms
67,456 KB
testcase_10 AC 40 ms
52,096 KB
testcase_11 AC 65 ms
67,456 KB
testcase_12 AC 74 ms
72,320 KB
testcase_13 AC 67 ms
66,688 KB
testcase_14 AC 73 ms
68,736 KB
testcase_15 AC 73 ms
71,168 KB
testcase_16 AC 71 ms
68,992 KB
testcase_17 AC 77 ms
72,832 KB
testcase_18 AC 76 ms
74,112 KB
testcase_19 AC 74 ms
71,680 KB
testcase_20 AC 72 ms
70,912 KB
testcase_21 AC 65 ms
66,176 KB
testcase_22 AC 73 ms
71,424 KB
testcase_23 AC 72 ms
71,168 KB
testcase_24 AC 73 ms
71,040 KB
testcase_25 AC 71 ms
69,504 KB
testcase_26 AC 76 ms
73,600 KB
testcase_27 AC 72 ms
70,656 KB
testcase_28 AC 68 ms
68,864 KB
testcase_29 AC 77 ms
73,728 KB
testcase_30 AC 74 ms
72,320 KB
testcase_31 AC 75 ms
72,320 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