結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー convexineqconvexineq
提出日時 2021-02-17 19:53:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 95 ms / 1,000 ms
コード長 865 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 87,376 KB
実行使用メモリ 82,236 KB
最終ジャッジ日時 2023-10-12 06:04:49
合計ジャッジ時間 6,098 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,676 KB
testcase_01 AC 70 ms
71,612 KB
testcase_02 AC 72 ms
71,556 KB
testcase_03 AC 70 ms
71,724 KB
testcase_04 AC 72 ms
71,636 KB
testcase_05 AC 69 ms
71,436 KB
testcase_06 AC 69 ms
71,672 KB
testcase_07 AC 71 ms
71,820 KB
testcase_08 AC 70 ms
71,820 KB
testcase_09 AC 70 ms
71,880 KB
testcase_10 AC 69 ms
71,488 KB
testcase_11 AC 70 ms
71,648 KB
testcase_12 AC 72 ms
71,736 KB
testcase_13 AC 70 ms
71,820 KB
testcase_14 AC 70 ms
71,572 KB
testcase_15 AC 69 ms
71,500 KB
testcase_16 AC 70 ms
71,808 KB
testcase_17 AC 70 ms
71,740 KB
testcase_18 AC 70 ms
71,608 KB
testcase_19 AC 69 ms
71,488 KB
testcase_20 AC 69 ms
71,484 KB
testcase_21 AC 74 ms
75,832 KB
testcase_22 AC 75 ms
75,824 KB
testcase_23 AC 81 ms
76,944 KB
testcase_24 AC 95 ms
82,236 KB
testcase_25 AC 78 ms
76,644 KB
testcase_26 AC 85 ms
77,720 KB
testcase_27 AC 83 ms
77,512 KB
testcase_28 AC 86 ms
77,704 KB
testcase_29 AC 95 ms
79,668 KB
testcase_30 AC 79 ms
76,856 KB
testcase_31 AC 79 ms
76,568 KB
testcase_32 AC 77 ms
76,656 KB
testcase_33 AC 77 ms
76,608 KB
testcase_34 AC 77 ms
76,468 KB
testcase_35 AC 76 ms
76,504 KB
testcase_36 AC 75 ms
76,156 KB
testcase_37 AC 78 ms
76,632 KB
testcase_38 AC 76 ms
76,496 KB
testcase_39 AC 77 ms
76,584 KB
testcase_40 AC 76 ms
76,672 KB
testcase_41 AC 77 ms
76,540 KB
testcase_42 AC 76 ms
76,288 KB
testcase_43 AC 87 ms
78,680 KB
testcase_44 AC 85 ms
77,316 KB
testcase_45 AC 71 ms
71,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Eratosthenes(N): #N以下の素数のリストを返す
    N+=1
    is_prime_list = [True]*N
    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]]

L,R = map(int,input().split())
primes = Eratosthenes(int(R**0.5)+100)
l = len(primes)
for p in primes[::-1]:
    if L <= p*p <= R:
        for q in primes[::-1]:
            if L <= p*q <= R:
                print(p*q)
                exit()

min_factor = [0]*(R-L+1)
for p in primes[::-1]:
    sind = (L+p-1)//p #gind = R//p
    for i in range(sind*p-L,R-L+1,p):
        min_factor[i] = p
    if L <= p <= R:
        min_factor[p-L] = 0
ans = val = 0
for i in range(R-L+1):
    if val <= min_factor[i]:
        ans = i
        val = min_factor[i]
print(ans+L)
0