結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー maspy
提出日時 2020-01-29 23:57:33
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 455 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 43,856 KB
最終ジャッジ日時 2024-09-16 03:09:02
合計ジャッジ時間 19,884 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 5
other RE * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,L = map(int,read().split())

U = 10 ** 7
is_prime = np.zeros(U,np.bool)
is_prime[2] = 1
is_prime[3::2] = 1
for p in range(3,U,2):
    if p*p >= U:
        break
    if is_prime[p]:
        is_prime[p*p::p+p] = 0

primes = np.where(is_prime)[0]
D = primes * (N-1)
answer = np.maximum(0, L - D + 1).sum()
print(answer)
0