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
2024-10-08 14:46:19
it should be prime or R not
2024-06-29 06:35:09
why miller-rabin wrong?
<snip>
[Simes]: don't post code here, use the forum.


Last edit: 2024-06-29 10:46:56
2024-03-11 06:28:01
AC AFTER 7 WA'S IZI PIZI BRUH PUT STRONGER CASES I FALL ASLEEP ZZZZZ
2024-01-10 10:50:35
learn the Miller Rabin Primality tests [cp-algorithms], easy in one go

Last edit: 2024-01-10 10:50:57
2023-12-17 13:51:00
Why is it TLE ?????
<snip>
[Simes]: don't post code here, use the forum.

Last edit: 2023-12-21 21:51:26
2022-11-17 17:14:23
1 time miller rabin also get ac
2021-04-16 06:42:23
Try to use deterministic Miller Rabin algorithm, it only takes 0.01sec for this problem.

Last edit: 2021-04-16 06:43:05
2021-02-13 12:31:54
time limit exceeded what to do ?
2020-10-22 20:53:27
why it is run time error?
2020-08-06 21:56:17
Use Miller Rabin Test, and get AC..
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.