結果

問題 No.1059 素敵な集合
ユーザー H3PO4H3PO4
提出日時 2020-05-22 21:59:52
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 569 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 86,016 KB
最終ジャッジ日時 2024-04-15 16:47:27
合計ジャッジ時間 3,834 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
59,392 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
from collections import defaultdict

L, R = map(int, input().split())


def primes(L, R):
    is_prime = [True] * (R + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(L, int(R ** 0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, R + 1, i):
            is_prime[j] = False
    return (i for i in range(L, R + 1) if is_prime[i])


P = tuple(primes(L, R))
d = defaultdict(lambda: float('inf'))
for p1, p2 in itertools.combinations(P, 2):
    d[p2] = min(d[p2], p2 % p1)
print(sum(d.values()))
0