PON - Prime or Not


Given the number, you are to answer the question: "Is it prime?"

Solutions to this problem can be submitted in C, C++, Pascal, Perl, Python, Ruby, Lisp, Hask, Ocaml, Prolog, Whitespace, Brainf**k and Intercal only.

Input

t – the number of test cases, then t test cases follows. [t <= 500]
Each line contains one integer: N [2 <= N <= 2^63-1]

Output

For each test case output string "YES" if given number is prime and "NO" otherwise.

Example

Input:
5
2
3
4
5
6

Output:
YES
YES
NO
YES
NO

hide comments
houda_bh: 2021-02-13 12:31:54

time limit exceeded what to do ?

princemishra: 2020-12-25 06:33:07

The AC feels good, but nothing beats the ephedrine hit of announcing to everyone my preference for prepubsecent boys!

Last edit: 2020-12-25 16:51:21
mamun_01_neub: 2020-10-22 20:53:27

why it is run time error?

chikku: 2020-08-06 21:56:17

Use Miller Rabin Test, and get AC..

vayuhu: 2020-08-02 10:34:40

Why is primality test of sqrt(N) is throwing TLE?

[NG]: Because sqrt(max_n) = 2^32.

Last edit: 2020-08-02 15:01:19
mehul007: 2020-07-26 00:23:40

0.00 sec with miller rabin

impulse15: 2020-07-23 20:25:01

can anyone provide the link of his code done by Fermat or miller method ??
i tried both but both gave the wrong answer

prasant35: 2020-07-14 23:47:59

how can i get AC in 0.00s ?my current best is 0.06s .

panther_786: 2020-07-14 09:28:22

Got AC with 2.68 sec using fermat's theorem.
Hint: Take care of overflow while multiplying.

Last edit: 2020-07-14 09:31:13
spoj_1105: 2020-06-23 07:08:20

my code was compiled in 14sec but still its showing tle. any suggestions why?


Added by:Roman Sol
Date:2005-01-24
Time limit:21s
Source limit:5000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ADA95 ASM32 BASH CSHARP CLPS D ERL FORTRAN ICON JAVA JS-RHINO LUA NEM NICE PHP PIKE ST
Resource:ZCon 2005