結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー nanaenanae
提出日時 2017-02-23 05:47:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 324 ms / 1,000 ms
コード長 889 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 49,320 KB
最終ジャッジ日時 2024-06-10 02:45:40
合計ジャッジ時間 3,078 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,880 KB
testcase_01 AC 27 ms
10,752 KB
testcase_02 AC 25 ms
10,880 KB
testcase_03 AC 33 ms
11,900 KB
testcase_04 AC 28 ms
10,752 KB
testcase_05 AC 26 ms
10,880 KB
testcase_06 AC 26 ms
10,880 KB
testcase_07 AC 26 ms
10,752 KB
testcase_08 AC 26 ms
10,880 KB
testcase_09 AC 26 ms
11,008 KB
testcase_10 AC 25 ms
10,752 KB
testcase_11 AC 26 ms
10,880 KB
testcase_12 AC 26 ms
10,880 KB
testcase_13 AC 29 ms
10,880 KB
testcase_14 AC 25 ms
10,880 KB
testcase_15 AC 25 ms
10,752 KB
testcase_16 AC 25 ms
10,880 KB
testcase_17 AC 27 ms
11,008 KB
testcase_18 AC 25 ms
10,752 KB
testcase_19 AC 54 ms
15,104 KB
testcase_20 AC 108 ms
22,596 KB
testcase_21 AC 26 ms
11,008 KB
testcase_22 AC 26 ms
10,752 KB
testcase_23 AC 27 ms
10,880 KB
testcase_24 AC 26 ms
10,880 KB
testcase_25 AC 169 ms
30,216 KB
testcase_26 AC 26 ms
10,880 KB
testcase_27 AC 26 ms
10,880 KB
testcase_28 AC 27 ms
10,752 KB
testcase_29 AC 25 ms
11,008 KB
testcase_30 AC 26 ms
10,880 KB
testcase_31 AC 25 ms
10,880 KB
testcase_32 AC 96 ms
20,504 KB
testcase_33 AC 309 ms
49,320 KB
testcase_34 AC 324 ms
49,192 KB
testcase_35 AC 157 ms
28,504 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