結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 39 ms
11,848 KB
testcase_04 AC 30 ms
10,752 KB
testcase_05 AC 31 ms
11,008 KB
testcase_06 AC 30 ms
10,880 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 31 ms
10,752 KB
testcase_09 AC 30 ms
10,880 KB
testcase_10 AC 30 ms
10,752 KB
testcase_11 AC 30 ms
10,752 KB
testcase_12 AC 30 ms
10,752 KB
testcase_13 AC 30 ms
10,752 KB
testcase_14 AC 30 ms
10,752 KB
testcase_15 AC 30 ms
10,880 KB
testcase_16 AC 29 ms
10,880 KB
testcase_17 AC 30 ms
10,752 KB
testcase_18 AC 29 ms
11,008 KB
testcase_19 AC 59 ms
14,800 KB
testcase_20 AC 117 ms
22,548 KB
testcase_21 AC 30 ms
10,880 KB
testcase_22 AC 30 ms
10,752 KB
testcase_23 AC 30 ms
10,880 KB
testcase_24 AC 30 ms
10,752 KB
testcase_25 AC 174 ms
30,168 KB
testcase_26 AC 30 ms
10,752 KB
testcase_27 AC 29 ms
10,752 KB
testcase_28 AC 30 ms
10,752 KB
testcase_29 AC 30 ms
10,752 KB
testcase_30 AC 30 ms
10,752 KB
testcase_31 AC 30 ms
10,752 KB
testcase_32 AC 101 ms
20,460 KB
testcase_33 AC 321 ms
48,960 KB
testcase_34 AC 321 ms
48,948 KB
testcase_35 AC 162 ms
28,336 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