Submit | All submissions | Best solutions | Back to list |
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
|
||||||||||||||
2016-07-07 10:05:30
miller rabin accptd! prime sieve algo dint work....! yes multiplication wd mod is obvious.! |
||||||||||||||
2016-07-03 01:25:31
miller rabin is working fine...wa with fermat. |
||||||||||||||
2016-06-30 18:31:28
I am getting WA in both fermat and miller |
||||||||||||||
2016-05-18 17:08:33
why i'm getting runtime error with prime sieve algo :( |
||||||||||||||
2016-03-24 10:43:47
take care of integer overflow |
||||||||||||||
2016-03-14 13:45:52
Submitted once - Wrong Answer. Submitted same code again - Accepted in 1.69 secs It's sad that we don't have a primality test that is deterministic |
||||||||||||||
2016-02-27 13:40:23 KAUSHAL AGRAWAL
so crazy time limit! distribute this time to other problems :P |
||||||||||||||
2016-02-26 13:04:56
plz tell me where my code is wrong |
||||||||||||||
2016-02-03 16:38:01
Done with MillerRabin Primality Test !! Done with Fermat Primality Test !! TakeCare of overflow, i first thought my algorithm is wrong , then submitted in python got AC.. Then learnt a new way handling Multiplication overflow...and got AC in CPP too!! Worth Solving!! Last edit: 2016-02-03 17:53:04 |
||||||||||||||
2016-01-01 21:40:27
Why we cannot solve it by simple method? |