結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー c-yan
提出日時 2020-11-19 00:20:43
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 617 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 206,708 KB
最終ジャッジ日時 2024-07-23 09:19:13
合計ジャッジ時間 6,222 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 2
other AC * 10 WA * 19 TLE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

def enumerate_primes(n):
    result = []
    sieve = list(range(max(n + 1, 2)))
    if n < 2:
        return result
    result.append(2)
    for i in range(4, n + 1, 2):
        sieve[i] = 2
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i] != i:
            continue
        result.append(i)
        for j in range(i * i, n + 1, i * 2):
            if sieve[j] == j:
                sieve[j] = i
    return result


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

    t = L // (N - 1)
    result = 0
    for d in enumerate_primes(t):
        result += L - d * (N - 1) + 1
    print(result)


main()
0