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

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

hide comments
2012-03-06 19:08:41 PubLic_AvenGeR
Finally after 33 submissions...... :))
Python does d trick...
1 iteration f little fermat theorem..
2012-02-05 11:06:06 libra
test cases are not proper!!i printed NO for 2,3,5 it accepted!!!
2012-01-22 21:21:00 Laplace
GOt accepted by 1 iteration with miller rabin...algo
2012-01-22 17:34:08 manish kapoor
6384521
i have implemented miller_rabin,but still i m getting WA.somebody pls tell me some tricky test cases......
2011-11-05 12:59:34 Jitesh
what max size of char array we can take on spoj.....can any one help????
2011-08-16 14:01:13 vit
ha again. my code get tle for 9223372036854775783, but ac in system
2011-08-16 09:05:06 vit
ha. my code write YES for 49141 and get AC...
2011-08-15 22:46:42 Pranay
solovay-strassen times out??
2011-05-14 01:53:16 Rohan Kalra
Very weak test cases. Only 1 iteration of Miller–Rabin required -_-
2011-05-04 12:21:40 Neeraj Bhat
for Endang wahyu pamungkas: n(2<=n<=2^63-1)
means n>2
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.