結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー yuppe19 😺yuppe19 😺
提出日時 2016-05-17 00:02:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 40 ms / 1,000 ms
コード長 824 bytes
コンパイル時間 843 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 10,208 KB
最終ジャッジ日時 2023-08-29 01:04:29
合計ジャッジ時間 3,715 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
10,016 KB
testcase_01 AC 40 ms
10,208 KB
testcase_02 AC 40 ms
10,008 KB
testcase_03 AC 38 ms
10,040 KB
testcase_04 AC 38 ms
10,148 KB
testcase_05 AC 39 ms
10,036 KB
testcase_06 AC 39 ms
10,164 KB
testcase_07 AC 38 ms
10,032 KB
testcase_08 AC 39 ms
10,200 KB
testcase_09 AC 39 ms
10,204 KB
testcase_10 AC 40 ms
9,964 KB
testcase_11 AC 40 ms
10,004 KB
testcase_12 AC 39 ms
10,016 KB
testcase_13 AC 39 ms
10,112 KB
testcase_14 AC 40 ms
10,024 KB
testcase_15 AC 38 ms
10,124 KB
testcase_16 AC 38 ms
9,988 KB
testcase_17 AC 40 ms
10,032 KB
testcase_18 AC 38 ms
10,036 KB
testcase_19 AC 39 ms
10,096 KB
testcase_20 AC 39 ms
10,108 KB
testcase_21 AC 38 ms
10,164 KB
testcase_22 AC 37 ms
10,008 KB
testcase_23 AC 39 ms
10,160 KB
testcase_24 AC 30 ms
10,108 KB
testcase_25 AC 31 ms
10,020 KB
testcase_26 AC 40 ms
10,092 KB
testcase_27 AC 30 ms
9,964 KB
testcase_28 AC 32 ms
10,028 KB
testcase_29 AC 32 ms
9,968 KB
testcase_30 AC 32 ms
10,044 KB
testcase_31 AC 32 ms
10,088 KB
testcase_32 AC 31 ms
10,116 KB
testcase_33 AC 32 ms
10,144 KB
testcase_34 AC 33 ms
10,016 KB
testcase_35 AC 33 ms
10,160 KB
testcase_36 AC 36 ms
10,016 KB
testcase_37 AC 31 ms
10,184 KB
testcase_38 AC 33 ms
10,160 KB
testcase_39 AC 32 ms
10,092 KB
testcase_40 AC 32 ms
10,112 KB
testcase_41 AC 33 ms
10,048 KB
testcase_42 AC 34 ms
10,040 KB
testcase_43 AC 32 ms
10,028 KB
testcase_44 AC 39 ms
10,024 KB
testcase_45 AC 40 ms
9,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python3
def sieve(n):
    is_prime = [0, 0] + [1] * (n-1)
    sq = int(n ** .5)
    for i in range(2, sq+1):
        if is_prime[i]:
            for j in range(i*i, n+1, i):
                is_prime[j] = 0
    return [i for i, p in enumerate(is_prime) if p]

from collections import defaultdict

def factorize(n):
    res = defaultdict(int)
    d = 2
    while d * d <= n:
        while n % d == 0:
            res[d] += 1
            n //= d
        d += 1
    if n > 1:
        res[n] += 1
    return res

L, H = map(int, input().split())
primes = sieve(10**5 + 100)
for p in primes[::-1]:
    l = (L+p-1) // p
    h = H // p
    for d in reversed(range(max(p, l), h+1)):
        fac = factorize(d)
        if min(list(fac.keys()) + [p]) == p:
            res = p * d
            print(res)
            exit(0)
0