結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー しらっ亭しらっ亭
提出日時 2016-08-06 00:57:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 304 ms / 1,000 ms
コード長 826 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 49,016 KB
最終ジャッジ日時 2024-12-15 22:52:53
合計ジャッジ時間 3,268 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,752 KB
testcase_01 AC 26 ms
10,880 KB
testcase_02 AC 27 ms
10,752 KB
testcase_03 AC 33 ms
11,852 KB
testcase_04 AC 30 ms
10,752 KB
testcase_05 AC 30 ms
10,880 KB
testcase_06 AC 29 ms
10,752 KB
testcase_07 AC 28 ms
10,624 KB
testcase_08 AC 26 ms
10,752 KB
testcase_09 AC 27 ms
10,752 KB
testcase_10 AC 26 ms
10,880 KB
testcase_11 AC 25 ms
10,880 KB
testcase_12 AC 27 ms
10,880 KB
testcase_13 AC 27 ms
10,752 KB
testcase_14 AC 26 ms
10,752 KB
testcase_15 AC 27 ms
10,752 KB
testcase_16 AC 26 ms
10,752 KB
testcase_17 AC 26 ms
10,752 KB
testcase_18 AC 29 ms
10,880 KB
testcase_19 AC 55 ms
14,680 KB
testcase_20 AC 114 ms
22,544 KB
testcase_21 AC 28 ms
10,752 KB
testcase_22 AC 27 ms
10,752 KB
testcase_23 AC 27 ms
10,752 KB
testcase_24 AC 27 ms
10,752 KB
testcase_25 AC 161 ms
30,164 KB
testcase_26 AC 27 ms
10,880 KB
testcase_27 AC 25 ms
10,752 KB
testcase_28 AC 25 ms
10,752 KB
testcase_29 AC 27 ms
10,752 KB
testcase_30 AC 26 ms
10,624 KB
testcase_31 AC 26 ms
10,752 KB
testcase_32 AC 90 ms
20,588 KB
testcase_33 AC 304 ms
48,956 KB
testcase_34 AC 292 ms
49,016 KB
testcase_35 AC 148 ms
28,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# パクった
def primes2(limit):
    ''' returns a list of prime numbers upto limit.
    source: Rossetta code: Sieve of Eratosthenes
    http://rosettacode.org/wiki/Sieve_of_Eratosthenes#Odds-only_version_of_the_array_sieve_above
    '''
    if limit < 2: return []
    if limit < 3: return [2]
    lmtbf = (limit - 3) // 2
    buf = [True] * (lmtbf + 1)
    for i in range((int(limit ** 0.5) - 3) // 2 + 1):
        if buf[i]:
            p = i + i + 3
            s = p * (i + 1) + i
            buf[s::p] = [False] * ((lmtbf - s) // p + 1)
    return [2] + [i + i + 3 for i, v in enumerate(buf) if v]


def solve():
    N, L = map(int, input().split())

    ps = primes2(L // (N - 1))

    ans = 0
    for p in ps:
        a = L - p * (N - 1)
        ans += a + 1
    print(ans)


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