結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー maspy
提出日時 2023-11-10 17:51:18
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 539 ms / 1,000 ms
コード長 456 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 73,276 KB
最終ジャッジ日時 2024-09-26 00:49:08
合計ジャッジ時間 20,420 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 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