結果

問題 No.1125 Without Parallelogram
ユーザー maspy
提出日時 2020-07-22 22:09:24
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 508 ms / 1,000 ms
コード長 619 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 44,604 KB
最終ジャッジ日時 2024-06-22 18:20:38
合計ジャッジ時間 19,755 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np

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

def prime_table(N):
    is_prime = np.zeros(N, np.int64)
    is_prime[2:3] = 1
    is_prime[3::2] = 1
    for p in range(3, N, 2):
        if p * p >= N:
            break
        if is_prime[p]:
            is_prime[p * p::p + p] = 0
    return is_prime, np.where(is_prime)[0]

_, primes = prime_table(10**4)

N = int(read())

def main(N):
    p = primes[primes > N][0]
    x = np.arange(N)
    y = (x * x) % p
    return x, y

x, y = main(N)
for a, b in zip(x, y):
    print(a, b)
0