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
spoj_1105: 2020-06-23 07:08:20

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

jpfr12: 2020-06-05 12:59:50

@sutharp777 sadly, we can not submit in Java or Kotlin.

lone_coderrr: 2020-06-05 09:50:16

Works great with Fermats little test just make sure to give it somewhere around 20 iteration, got AC in 0.10s using python!

sutharp777: 2020-05-29 13:57:41

in java it's easy just isProbablePrime(10) in java.math.BigInteger.

gr523: 2020-05-27 15:43:10

BigMod alone can not take care of overflow

nutpeabutter: 2020-05-15 14:42:39

Time limit exceeded on PY, but it fine works on IDEone

shivamvermadev: 2020-04-04 20:29:45

I am using MIller Rabin Test but still getting wrong ans
any suggestions . My Sol id is 25696991

firefox_30: 2020-03-28 01:56:32

What are the compile options for Rust, particularly the optimization level? When will be the next update?

zufius: 2020-03-20 04:36:04

time limit is 21s and I got AC in 0.00s. is it because the server is much stronger than 15 years ago ? or the test cases are too weak ?

god_coder: 2019-11-23 18:23:10

Used Miller Rabbin. AC in one go :)


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