結果

問題 No.6 使いものにならないハッシュ
ユーザー convexineqconvexineq
提出日時 2020-11-24 05:28:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,162 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 87,288 KB
実行使用メモリ 80,468 KB
最終ジャッジ日時 2023-10-01 00:47:06
合計ジャッジ時間 5,524 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
78,512 KB
testcase_01 AC 89 ms
78,568 KB
testcase_02 AC 97 ms
79,808 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def Eratosthenes(N): #N以下の素数のリストを返す
    #iが素数のときis_prime_list[i]=1,それ以外は0
    N+=1
    is_prime_list = [True]*N
#    is_prime_list[0], is_prime_list[1] = False, False #リストが必要なときはこの2行を有効化
#    for j in range(4,N,2): is_prime_list[j] = False
    m = int(N**0.5)+1
    for i in range(3,m,2):
        if is_prime_list[i]:
            is_prime_list[i*i::2*i]=[False]*((N-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,N,2) if is_prime_list[i]]

# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#a,b,c = map(int,readline().split())

k = int(input())
n = int(input())
primes = [i for i in Eratosthenes(2*10**5) if k <= i <= n]
res = [i%9 for i in primes]

idx = n
val = 0
n = len(res)
s = set()
for i in range(n-1,-1,-1):
    cnt = 0
    for j in range(i,-1,-1):
        if res[j] not in s:
            cnt += 1
            s.add(res[j])
        else:
            #print(j,i,s)
            if val <= i-j:
                val = i-j
                idx = j+1
            break
    s.clear()    

#print(idx)
print(primes[idx])






0