結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー nanaenanae
提出日時 2017-02-23 05:39:36
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 312 ms / 1,000 ms
コード長 849 bytes
コンパイル時間 376 ms
コンパイル使用メモリ 87,372 KB
実行使用メモリ 140,264 KB
最終ジャッジ日時 2023-08-30 03:29:45
合計ジャッジ時間 5,311 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,392 KB
testcase_01 AC 71 ms
71,676 KB
testcase_02 AC 70 ms
71,620 KB
testcase_03 AC 82 ms
77,056 KB
testcase_04 AC 69 ms
71,576 KB
testcase_05 AC 70 ms
71,744 KB
testcase_06 AC 70 ms
71,388 KB
testcase_07 AC 70 ms
71,468 KB
testcase_08 AC 70 ms
71,632 KB
testcase_09 AC 72 ms
71,096 KB
testcase_10 AC 71 ms
71,344 KB
testcase_11 AC 71 ms
71,424 KB
testcase_12 AC 72 ms
71,752 KB
testcase_13 AC 70 ms
71,440 KB
testcase_14 AC 74 ms
75,532 KB
testcase_15 AC 71 ms
71,388 KB
testcase_16 AC 71 ms
71,668 KB
testcase_17 AC 70 ms
71,232 KB
testcase_18 AC 71 ms
71,476 KB
testcase_19 AC 93 ms
81,988 KB
testcase_20 AC 134 ms
94,744 KB
testcase_21 AC 71 ms
71,464 KB
testcase_22 AC 73 ms
71,476 KB
testcase_23 AC 71 ms
71,236 KB
testcase_24 AC 73 ms
71,280 KB
testcase_25 AC 189 ms
107,468 KB
testcase_26 AC 72 ms
71,232 KB
testcase_27 AC 71 ms
71,420 KB
testcase_28 AC 70 ms
71,432 KB
testcase_29 AC 71 ms
71,476 KB
testcase_30 AC 71 ms
71,232 KB
testcase_31 AC 71 ms
71,688 KB
testcase_32 AC 123 ms
91,764 KB
testcase_33 AC 311 ms
140,264 KB
testcase_34 AC 312 ms
140,232 KB
testcase_35 AC 171 ms
105,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from math import sqrt

def solve():
    N, L = map(int, input().split())
    limit = L // (N - 1) + 1
    primes = make_primes(limit)
    # debug(primes, locals())

    ans = 0

    for p in primes:
        if L - (N - 1) * p + 1 <= 0:
            break
        ans += L - (N - 1) * p + 1

    print(ans)

def make_primes(limit):
    primes = [True] * (limit + 1)
    primes[0], primes[1] = False, False

    for p in range(2, int(sqrt(limit)) + 1):
        if not primes[p]:
            continue
        for k in range(p*p, limit + 1, p):
            primes[k] = False

    return [p for p in range(limit + 1) if primes[p]]

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

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