結果

問題 No.1125 Without Parallelogram
コンテスト
ユーザー maspy
提出日時 2020-07-22 22:09:24
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 913 ms / 1,000 ms
コード長 619 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 610 ms
コンパイル使用メモリ 20,956 KB
実行使用メモリ 35,164 KB
最終ジャッジ日時 2026-03-06 23:33:44
合計ジャッジ時間 32,945 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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