Sphere Online Judge

Computer geeks! Show off your skills and claim the job of your dreams! RecruitCoders.com

SPOJ Problem Set (classical)

3587. Prime Again

Problem code: PAGAIN

In this problem, you have to find the nearest prime number smaller than N. (3 <= N <= 2^32)

Input

The first line contains an integer T specifying the number of test cases. (T <= 10000)

T lines follow, each line contains an integer N.

Output

For each test case, output the result on one line.

Example

Input:
3
5 
10
17

Output:
3
7
13

Added by:Race with time
Date:2008-12-25
Time limit:5s
Source limit:50000B
Languages:All except: ERL JS PERL 6

hide comments
2011-05-21 12:56:46 Rohan Kalra
Miller-Rabin works fine!
2011-02-05 14:55:54 sandeep pandey
Done!!!

Last edit: 2011-03-26 08:27:47
2010-06-07 17:39:15 .:: Debanjan ::.

I used a slight different version of Miller-Rabin test to get an accepted verdict.


Last edit: 2010-06-07 17:39:32
2010-04-26 21:05:40 XeRoN!X
@Debanjan I think there are more than 1 input sets with t test cases each. For each of them time limit is 5s. Time which is shown in result is the total time taken to print output for all input sets.
2010-04-09 14:05:43 .:: Debanjan ::.

The time limit is of 5 secs,then how come 8+ secs solution got accepted ?

EDIT:Old solutions should be rejudged.

Last edit: 2010-04-09 16:57:32
SPOJ System © 2012 Sphere Research Labs | Projekty informatyczne i aplikacje na zamówienie. All Rights Reserved.