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
|
||||||||||||||
2015-08-28 00:26:45
My first ever implementation of Miller Rabin. Learnt a lot. :) |
||||||||||||||
2015-08-26 16:11:57 Mohit Rathore
http://www.spoj.com/problems/ZSUM/ Solve this first! |
||||||||||||||
2015-07-03 14:28:27 SangKuan
AC but still do not understand then Miller rabin |
||||||||||||||
2015-06-05 20:46:08 kartikay singh
JUST 1 ITERATION OF MILLER RABIN :) check for overflows Costed me a WA... |
||||||||||||||
2015-04-26 22:33:44 _R0b_
go with : - > Miller rabin |
||||||||||||||
2015-04-09 18:38:13 Madhav
miller rabin works!! |
||||||||||||||
2015-03-10 08:37:19 Sayak Haldar
This problem has weak test cases....there is no checking for pseudoprimes (like 9,2047. etc) Last edit: 2015-03-11 17:45:27 |
||||||||||||||
2015-01-23 22:08:16 Abhinandan Agarwal
Accepted with Miller Rabin , but failed with Fermat's probability test ... Any help ? Anyone who solved it using fermat's little theorem ? |
||||||||||||||
2015-01-18 05:54:22 lovecode
learned a new thing............AC finally Last edit: 2015-01-18 05:55:07 |
||||||||||||||
2014-10-25 10:40:02 Kriti Joshi
So much to learn in a single ques!! adorable, but 0 point Last edit: 2014-10-25 10:40:38 |