結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー htkbhtkb
提出日時 2018-05-27 14:20:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 844 ms / 1,000 ms
コード長 354 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 10,752 KB
実行使用メモリ 217,524 KB
最終ジャッジ日時 2023-09-11 03:55:44
合計ジャッジ時間 5,313 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,876 KB
testcase_01 AC 16 ms
7,896 KB
testcase_02 AC 17 ms
7,964 KB
testcase_03 AC 32 ms
14,312 KB
testcase_04 AC 16 ms
7,968 KB
testcase_05 AC 17 ms
7,960 KB
testcase_06 AC 16 ms
8,012 KB
testcase_07 AC 16 ms
8,076 KB
testcase_08 AC 16 ms
7,916 KB
testcase_09 AC 16 ms
7,920 KB
testcase_10 AC 17 ms
8,036 KB
testcase_11 AC 16 ms
8,072 KB
testcase_12 AC 16 ms
7,960 KB
testcase_13 AC 16 ms
7,952 KB
testcase_14 AC 17 ms
7,960 KB
testcase_15 AC 16 ms
7,876 KB
testcase_16 AC 16 ms
7,900 KB
testcase_17 AC 16 ms
7,976 KB
testcase_18 AC 16 ms
7,916 KB
testcase_19 AC 84 ms
28,224 KB
testcase_20 AC 252 ms
77,124 KB
testcase_21 AC 17 ms
8,028 KB
testcase_22 AC 17 ms
7,980 KB
testcase_23 AC 16 ms
7,908 KB
testcase_24 AC 17 ms
7,908 KB
testcase_25 AC 414 ms
112,800 KB
testcase_26 AC 16 ms
7,924 KB
testcase_27 AC 16 ms
7,944 KB
testcase_28 AC 16 ms
7,968 KB
testcase_29 AC 16 ms
8,076 KB
testcase_30 AC 16 ms
7,924 KB
testcase_31 AC 16 ms
7,960 KB
testcase_32 AC 208 ms
60,108 KB
testcase_33 AC 844 ms
217,524 KB
testcase_34 AC 841 ms
217,472 KB
testcase_35 AC 381 ms
109,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt
N, L = map(int, input().split())
max_interval = int(L//(N-1))

primes = set(range(3, max_interval+1, 2))
if max_interval >= 2:
    primes.add(2)

du = primes.difference_update
for i in range(3, int(sqrt(max_interval))+1, 2):
    if i in primes:
        du(range(i*3, max_interval+1, i*2))

print((L+1)*len(primes)+(1-N)*sum(primes))
0