AMR11E - Distinct Primes

Arithmancy is Draco Malfoy's favorite subject, but what spoils it for him is that Hermione Granger is in his class, and she is better than him at it. Prime numbers are of mystical importance in Arithmancy, and Lucky Numbers even more so. Lucky Numbers are those positive integers that have at least three distinct prime factors; 30 and 42 are the first two. Malfoy's teacher has given them a positive integer n, and has asked them to find the n-th lucky number. Malfoy would like to beat Hermione at this exercise, so although he is an evil git, please help him, just this once. After all, the know-it-all Hermione does need a lesson.

Input

The first line contains the number of test cases T. Each of the next T lines contains one integer n.

Output

Output T lines, containing the corresponding lucky number for that test case.

Constraints

1 <= T <= 20
1 <= n <= 1000

Example

Sample Input:
2
1
2

Sample Output:
30
42

Added by:Varun Jalan
Date:2011-12-15
Time limit:3s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Varun Jalan - ICPC Asia regionals, Amritapuri 2011

hide comments
2016-09-06 15:57:47
how to see editorial in spoj for all problems
2016-09-05 09:00:03 Anuj Arora
AC in one go!!!
2016-08-29 09:01:35
yeaaah!! AC in one go. sieve + brute force= answer


Last edit: 2016-08-29 09:02:14
2016-07-30 08:46:43 Rezaul H Sagar
map<int,int> gives me 2988 is the 1000th lucky number :/
2016-06-09 23:17:05
how are you all doing it....my 568th lucky number is 2664
...anybody can help?

Last edit: 2016-06-09 23:17:30
2016-06-03 13:14:17
use sieve().... AC :-)
2016-05-10 21:08:52
sieve...:P :P ac in one go :) :)
2016-05-09 19:24:03
hint is 2*3*5 is 30 and 2*3*2*5 =60 is also lucky number.

I wasted lot of time in following this sequence... https://oeis.org/A007304/b007304.txt
It is simple... don't complicate the life.
2016-05-09 19:19:09
Weird... I thought, this is the answer... But, it seems to be different... https://oeis.org/A007304/b007304.txt
2016-04-08 12:50:03 hareesh
Brute force C-> AC in 0.00s :D

Just remembr 1000th lucky number is 2664
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.