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. 服务发现 consul cluster 的搭建

    consul cluster setup 介绍和指南: consul用于服务发现.当底层服务发生变化时,能及时更新正确的mysql服务IP. 并提供给业务查询.但需要自行编写脚本,监测数据库状态和切断 ...

  2. parseObject方法将json字符串转换成Map

    String nwVal=recordDO.getWorkOrderNwVal(); HashMap<String,WxhcWorkOrderDO> nwMap=JSON.parseObj ...

  3. 数据库-mysql函数

    一:MySQL中提供了许多内置函数 CHAR_LENGTH(str) 返回值为字符串str 的长度,长度的单位为字符.一个多字节字符算作一个单字符. 对于一个包含五个二字节字符集, LENGTH()返 ...

  4. CRF条件随机场

    CRF的进化 https://flystarhe.github.io/2016/07/13/hmm-memm-crf/参考: http://blog.echen.me/2012/01/03/intro ...

  5. 详解MySQL大表优化方案

    单表优化 除非单表数据未来会一直不断上涨,否则不要一开始就考虑拆分,拆分会带来逻辑.部署.运维的各种复杂度,一般以整型值为主的表在千万级以下,字符串为主的表在五百万以下是没有太大问题的.而事实上很多时 ...

  6. 汇编看C函数调用

    http://blog.csdn.net/wishfly/article/details/5022008   简单的函数调用,通过简单的函数调用反汇编可以清楚了解如下 1.栈到底是什么,如何操纵栈的? ...

  7. Centos之链接命令

    链接命令:ln  (link) ln -s [源文件] [目标文件] 功能描述:生成链接文件 选项: -s 创建软链接 硬链接特征: 1,拥有相同的i节点和存储block块,可以看作是同一个文件: 2 ...

  8. python类、类继承

    yield: 简单地讲,yield 的作用就是把一个函数变成一个 generator,带有 yield 的函数不再是一个普通函数,Python 解释器会将其视为一个 generator,调用 fab( ...

  9. **CodeIgniter-cURL扩展

    Work with cURL easily from your CodeIgniter application. Tweet Contributor : philsturgeon Email : Lo ...

  10. Eclipse+Tomcat+Axis2+ADT开发环境配置

    一.安装Eclipse和Tomcat 1.安装Eclipse: 2.解压缩安装apache-tomcat-6.0.41 3.tomcat配置环境变量(4个) TOMCAT_HOME     D:\An ...