結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー 👑 yumechiyumechi
提出日時 2016-08-26 00:37:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 473 ms / 1,000 ms
コード長 578 bytes
コンパイル時間 201 ms
コンパイル使用メモリ 82,500 KB
実行使用メモリ 153,800 KB
最終ジャッジ日時 2024-04-25 18:01:55
合計ジャッジ時間 4,333 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,120 KB
testcase_01 AC 37 ms
53,744 KB
testcase_02 AC 35 ms
52,736 KB
testcase_03 AC 57 ms
70,800 KB
testcase_04 AC 34 ms
53,600 KB
testcase_05 AC 126 ms
131,920 KB
testcase_06 AC 89 ms
99,112 KB
testcase_07 AC 36 ms
52,900 KB
testcase_08 AC 36 ms
52,608 KB
testcase_09 AC 35 ms
53,668 KB
testcase_10 AC 35 ms
52,252 KB
testcase_11 AC 36 ms
52,904 KB
testcase_12 AC 38 ms
58,488 KB
testcase_13 AC 36 ms
58,348 KB
testcase_14 AC 40 ms
59,292 KB
testcase_15 AC 33 ms
52,824 KB
testcase_16 AC 36 ms
57,532 KB
testcase_17 AC 37 ms
58,452 KB
testcase_18 AC 37 ms
57,604 KB
testcase_19 AC 69 ms
74,040 KB
testcase_20 AC 120 ms
96,092 KB
testcase_21 AC 49 ms
68,796 KB
testcase_22 AC 46 ms
65,824 KB
testcase_23 AC 54 ms
74,116 KB
testcase_24 AC 68 ms
80,832 KB
testcase_25 AC 225 ms
114,804 KB
testcase_26 AC 79 ms
97,516 KB
testcase_27 AC 43 ms
63,856 KB
testcase_28 AC 56 ms
74,764 KB
testcase_29 AC 80 ms
95,776 KB
testcase_30 AC 50 ms
66,080 KB
testcase_31 AC 74 ms
88,860 KB
testcase_32 AC 127 ms
109,124 KB
testcase_33 AC 458 ms
153,800 KB
testcase_34 AC 473 ms
153,712 KB
testcase_35 AC 270 ms
146,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt

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