結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー nanaenanae
提出日時 2017-02-23 05:47:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 296 ms / 1,000 ms
コード長 889 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 46,664 KB
最終ジャッジ日時 2023-08-30 03:29:39
合計ジャッジ時間 3,121 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,464 KB
testcase_01 AC 16 ms
8,488 KB
testcase_02 AC 18 ms
8,208 KB
testcase_03 AC 24 ms
9,568 KB
testcase_04 AC 16 ms
8,480 KB
testcase_05 AC 16 ms
8,484 KB
testcase_06 AC 16 ms
8,496 KB
testcase_07 AC 17 ms
8,484 KB
testcase_08 AC 17 ms
8,584 KB
testcase_09 AC 16 ms
8,456 KB
testcase_10 AC 16 ms
8,556 KB
testcase_11 AC 17 ms
8,256 KB
testcase_12 AC 16 ms
8,336 KB
testcase_13 AC 17 ms
8,568 KB
testcase_14 AC 16 ms
8,460 KB
testcase_15 AC 16 ms
8,208 KB
testcase_16 AC 17 ms
8,580 KB
testcase_17 AC 16 ms
8,608 KB
testcase_18 AC 16 ms
8,088 KB
testcase_19 AC 45 ms
12,304 KB
testcase_20 AC 97 ms
20,272 KB
testcase_21 AC 16 ms
8,044 KB
testcase_22 AC 16 ms
8,460 KB
testcase_23 AC 16 ms
8,556 KB
testcase_24 AC 16 ms
8,604 KB
testcase_25 AC 149 ms
27,768 KB
testcase_26 AC 16 ms
8,092 KB
testcase_27 AC 16 ms
8,356 KB
testcase_28 AC 16 ms
8,456 KB
testcase_29 AC 17 ms
8,500 KB
testcase_30 AC 17 ms
8,552 KB
testcase_31 AC 17 ms
8,572 KB
testcase_32 AC 82 ms
18,160 KB
testcase_33 AC 294 ms
46,664 KB
testcase_34 AC 296 ms
46,640 KB
testcase_35 AC 136 ms
26,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from math import sqrt

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

    ans = 0

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

    print(ans)

def rwh_primes1(n):
    # http://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188
    """ Returns  a list of primes < n """
    sieve = [True] * (n//2)
    for i in range(3,int(n**0.5)+1,2):
        if sieve[i//2]:
            sieve[i*i//2::i] = [False] * ((n-i*i-1)//(2*i)+1)
    return [2] + [2*i+1 for i in range(1,n//2) if sieve[i]]

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