結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー 👑 yumechiyumechi
提出日時 2016-08-26 00:32:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 406 ms / 1,000 ms
コード長 559 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 82,212 KB
実行使用メモリ 150,932 KB
最終ジャッジ日時 2024-04-25 18:01:17
合計ジャッジ時間 5,228 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,624 KB
testcase_01 AC 32 ms
52,796 KB
testcase_02 AC 34 ms
52,880 KB
testcase_03 AC 62 ms
67,836 KB
testcase_04 AC 35 ms
52,928 KB
testcase_05 AC 365 ms
134,584 KB
testcase_06 AC 200 ms
99,964 KB
testcase_07 AC 40 ms
52,884 KB
testcase_08 AC 35 ms
53,096 KB
testcase_09 AC 32 ms
53,552 KB
testcase_10 AC 39 ms
58,480 KB
testcase_11 AC 35 ms
52,380 KB
testcase_12 AC 40 ms
59,328 KB
testcase_13 AC 38 ms
58,660 KB
testcase_14 AC 39 ms
59,404 KB
testcase_15 AC 34 ms
52,744 KB
testcase_16 AC 35 ms
58,408 KB
testcase_17 AC 37 ms
59,860 KB
testcase_18 AC 34 ms
58,176 KB
testcase_19 AC 61 ms
68,784 KB
testcase_20 AC 113 ms
87,548 KB
testcase_21 AC 67 ms
69,448 KB
testcase_22 AC 62 ms
67,736 KB
testcase_23 AC 84 ms
74,168 KB
testcase_24 AC 119 ms
82,676 KB
testcase_25 AC 197 ms
104,436 KB
testcase_26 AC 178 ms
98,184 KB
testcase_27 AC 55 ms
65,016 KB
testcase_28 AC 87 ms
77,048 KB
testcase_29 AC 190 ms
98,480 KB
testcase_30 AC 58 ms
66,272 KB
testcase_31 AC 149 ms
91,204 KB
testcase_32 AC 187 ms
101,568 KB
testcase_33 AC 402 ms
149,628 KB
testcase_34 AC 406 ms
150,932 KB
testcase_35 AC 346 ms
136,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt

def solve():
    n, l = map(int, input().split())
    ans = 0
    if l <= 3:
        print(0)
        return
    primes = [True for _ in range(l)]
    primes[0], primes[1] = False, False
    for i in range(2, int(sqrt(l)) + 1):
        if primes[i]:
            for j in range(2, l // i - 1):
                primes[i * j] = False

    for i in range(2, l):
        if primes[i]:
            t = (l + 1) - (n - 1) * i
            if t <= 0:
                break
            ans += t
    print(ans)

if __name__=="__main__":
    solve()
0