結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー eitaho
提出日時 2016-05-14 10:28:23
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 99 ms / 1,000 ms
コード長 498 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2024-12-30 18:11:42
合計ジャッジ時間 4,302 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
L, R = map(int, input().split())
ans, maxP = 0, 0
sqrt = int(R**0.5)
N = sqrt + 10
isprime = [1] * N

for i in range(2, N):
    if isprime[i]:
        for b in range(i + i, N, i):
            isprime[b] = 0
primes = [p for p in range(2, N) if isprime[p]]
smaller = list(primes)

for p in reversed(primes):
    smaller.pop()
    for x in reversed(range(max(p * p, (L + p - 1) // p * p), R + 1, p)):
        if all(x % b != 0 for b in smaller):
            print(x)
            sys.exit()
0