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 nth 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 (STDIN):

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

Output (STDOUT):

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

Constraints:

1 <= T <= 20

1 <= n <= 1000

Sample Input:

2

1

2

 ,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,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
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
};
/*int main()
{ int o=1,flag;
for(int m=1;m<100000;m++)
{
if(
((m%2==0)&&(m%3==0)&&(m%5==0))||
((m%2==0)&&(m%3==0)&&(m%7==0))||
((m%2==0)&&(m%3==0)&&(m%11==0))||
((m%2==0)&&(m%3==0)&&(m%13==0))||
((m%2==0)&&(m%3==0)&&(m%17==0))||
((m%2==0)&&(m%3==0)&&(m%19==0))||
((m%2==0)&&(m%7==0)&&(m%5==0))||
((m%2==0)&&(m%11==0)&&(m%5==0))||
((m%2==0)&&(m%13==0)&&(m%5==0))||
((m%2==0)&&(m%17==0)&&(m%5==0))||
((m%2==0)&&(m%19==0)&&(m%5==0))||
((m%2==0)&&(m%7==0)&&(m%11==0))||
((m%2==0)&&(m%7==0)&&(m%13==0))||
((m%2==0)&&(m%7==0)&&(m%17==0))||
((m%2==0)&&(m%7==0)&&(m%19==0))||
((m%2==0)&&(m%11==0)&&(m%13==0))||
((m%2==0)&&(m%11==0)&&(m%17==0))||
((m%2==0)&&(m%11==0)&&(m%19==0))||
((m%2==0)&&(m%13==0)&&(m%17==0))||
((m%2==0)&&(m%17==0)&&(m%19==0))||
((m%3==0)&&(m%7==0)&&(m%5==0))||
((m%11==0)&&(m%3==0)&&(m%5==0))||
((m%13==0)&&(m%3==0)&&(m%5==0))||
((m%17==0)&&(m%3==0)&&(m%5==0))||
((m%19==0)&&(m%3==0)&&(m%5==0))||
((m%7==0)&&(m%3==0)&&(m%11==0))||
((m%7==0)&&(m%3==0)&&(m%13==0))||
((m%7==0)&&(m%3==0)&&(m%17==0))||
((m%7==0)&&(m%3==0)&&(m%19==0))||
((m%11==0)&&(m%3==0)&&(m%13==0))||
((m%11==0)&&(m%3==0)&&(m%17==0))||
((m%11==0)&&(m%3==0)&&(m%19==0))||
((m%13==0)&&(m%3==0)&&(m%17==0))||
((m%13==0)&&(m%3==0)&&(m%19==0))||
((m%17==0)&&(m%3==0)&&(m%19==0))||
((m%11==0)&&(m%7==0)&&(m%5==0))||
((m%13==0)&&(m%7==0)&&(m%5==0))||
((m%17==0)&&(m%7==0)&&(m%5==0))||
((m%19==0)&&(m%7==0)&&(m%5==0))||
((m%17==0)&&(m%11==0)&&(m%5==0))||
((m%19==0)&&(m%11==0)&&(m%5==0))||
((m%13==0)&&(m%11==0)&&(m%5==0))||
((m%13==0)&&(m%11==0)&&(m%7==0))||
((m%17==0)&&(m%11==0)&&(m%7==0))||
((m%19==0)&&(m%11==0)&&(m%7==0))||
((m%17==0)&&(m%13==0)&&(m%11==0))||
((m%19==0)&&(m%13==0)&&(m%11==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0))||
((m%19==0)&&(m%17==0)&&(m%13==0)) )
{
flag=0;
for(int q=m-1;q>0;q--)
{
if(a[q]==m)
flag=1;
}
if(flag==0)
{
a[o]=m;
o=o+1;
}
}
}
int n;
scanf("%d",&n);
FILE *fp;//建立一个文件操作指针
fp=fopen("1.txt","w+");//以追加的方式建立或打开1.txt,默认位置在你程序的目录下面
for(int i=0;i<n;i++)
{ printf("%d\n",a[i]);
fprintf(fp,"%d,\n",a[i]);
}
return 0;
} */
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
int m;
scanf("%d",&m);
printf("%d\n",a[m]);
}
return ;
}

SPOJ 10232. Distinct Primes的更多相关文章

  1. SPOJ AMR11E Distinct Primes 基础数论

    Arithmancy is Draco Malfoy's favorite subject, but what spoils it for him is that Hermione Granger i ...

  2. (Problem 47)Distinct primes factors

    The first two consecutive numbers to have two distinct prime factors are: 14 = 2  7 15 = 3  5 The fi ...

  3. 【SPOJ】Distinct Substrings(后缀自动机)

    [SPOJ]Distinct Substrings(后缀自动机) 题面 Vjudge 题意:求一个串的不同子串的数量 题解 对于这个串构建后缀自动机之后 我们知道每个串出现的次数就是\(right/e ...

  4. 【SPOJ】Distinct Substrings/New Distinct Substrings(后缀数组)

    [SPOJ]Distinct Substrings/New Distinct Substrings(后缀数组) 题面 Vjudge1 Vjudge2 题解 要求的是串的不同的子串个数 两道一模一样的题 ...

  5. 【SPOJ】Distinct Substrings

    [SPOJ]Distinct Substrings 求不同子串数量 统计每个点有效的字符串数量(第一次出现的) \(\sum\limits_{now=1}^{nod}now.longest-paren ...

  6. SPOJ 694. Distinct Substrings (后缀数组不相同的子串的个数)转

    694. Distinct Substrings Problem code: DISUBSTR   Given a string, we need to find the total number o ...

  7. SPOJ 694 Distinct Substrings

    Distinct Substrings Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on SPOJ. O ...

  8. Project Euler:Problem 47 Distinct primes factors

    The first two consecutive numbers to have two distinct prime factors are: 14 = 2 × 7 15 = 3 × 5 The ...

  9. SPOJ 705 Distinct Substrings(后缀数组)

    [题目链接] http://www.spoj.com/problems/SUBST1/ [题目大意] 给出一个串,求出不相同的子串的个数. [题解] 对原串做一遍后缀数组,按照后缀的名次进行遍历, 每 ...

随机推荐

  1. 转载-struts中logic标签使用

    Struts中Logic逻辑标签的作用及用法 Struts中Logic逻辑标签的作用及用法 2006年10月18日 星期三 21:34 Terry原创,转载请说明作者及出处 Logic标签大部分的功能 ...

  2. python socket编程和黏包问题

    一.基于TCP的socket tcp是基于链接的,必须先启动服务端,然后再启动客户端去链接服务端,有顺序,不重复,可靠.不会被加上数据边界. server端 import socket sk = so ...

  3. Android浮动窗口的实现

    1.浮动窗口的实现原理 看到上图的那个小Android图标了吧,它不会被其他组建遮挡,也可以响应用户的点击和拖动事件,它的显示和消失由WindowManager直接管理,它就是Android浮动窗口. ...

  4. AngularJS中ng-class使用方法

    转自:https://blog.csdn.net/jumtre/article/details/50802136 其他博文ng-class使用方法:https://blog.csdn.net/sina ...

  5. Scala中“=>”用法及含义

    => has several meanings in Scala, all related to its mathematical meaning as implication. 1. In a ...

  6. MySQL学习笔记:循环生成5万行id连续的数据

    # ---- mysql循环生成5万行id连续的数据 ---- /* id 1 2 3 4 …… */ CREATE TABLE tb( id ) NOT NULL AUTO_INCREMENT, V ...

  7. C#socket编程序(一)

    在讲socket编程之前,我们先看一下最常用的一些类和方法,相信这些能让你事半功倍. 一.IP地址操作类 1.IPaddress类 a.在该类中有一个 parse()方法,能够把点分十进制IP地址 转 ...

  8. WebApi 插件式构建方案:集成加载数据库连接字符串

    body { border: 1px solid #ddd; outline: 1300px solid #fff; margin: 16px auto; } body .markdown-body ...

  9. spring boot之使用通用Mapper批量添加数据

    通用Mapper是一款针对mybatis进行扩展的轻量级组件,使用起来非常方便.当调用其针对mysql进行批量添加数据的方法时,发现报错,仔细研究了一番,发现是在使用通用Mapper上出现了问题.下面 ...

  10. USACO 5.5 Hidden Password

    Hidden Password ACM South Eastern Europe -- 2003 Sometimes the programmers have very strange ways of ...