問題一覧 > 教育的問題

No.8030 Test of the Miller-Rabin Primality Test

レベル : / 実行時間制限 : 1ケース 9.973秒 / メモリ制限 : 509 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 166
作問者 : yuppe19 😺
お気に入りにしたユーザー ProblemId : 1967 / 自分の提出
問題文最終更新日: 2019-03-11 11:24:51
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original

Problem Statement

For each of the given $n$ positive integers, determine whether it is prime.

Input

$n$
$x_{0}$
$x_{1}$
...
$x_{n-1}$

The first line contains the number of queries $n$.
The second and subsequent lines contain the $n$ positive integers to be tested for primality.
・$n$ is a positive integer.
・$1 \le n \le 10{,}000$
・$1 \le x_{i} \lt 2^{63}$ (fits in a 64-bit signed integer)

Output

For each positive integer,
output the value and whether it is prime (1 if it is prime, 0 otherwise), separated by a single-byte space, preserving the input order, followed by a newline.

Sample

Input
4
10
2
1
5
Output
10 0
2 1
1 0
5 1

Since the first line is 4, primality is tested for 4 positive integers.
10 and 1 are not prime, so output the number itself and a space, followed by 0;
2 and 5 are prime, so output 1.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。