SPOJ 10232. 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 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的更多相关文章
- SPOJ AMR11E Distinct Primes 基础数论
Arithmancy is Draco Malfoy's favorite subject, but what spoils it for him is that Hermione Granger i ...
- (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 ...
- 【SPOJ】Distinct Substrings(后缀自动机)
[SPOJ]Distinct Substrings(后缀自动机) 题面 Vjudge 题意:求一个串的不同子串的数量 题解 对于这个串构建后缀自动机之后 我们知道每个串出现的次数就是\(right/e ...
- 【SPOJ】Distinct Substrings/New Distinct Substrings(后缀数组)
[SPOJ]Distinct Substrings/New Distinct Substrings(后缀数组) 题面 Vjudge1 Vjudge2 题解 要求的是串的不同的子串个数 两道一模一样的题 ...
- 【SPOJ】Distinct Substrings
[SPOJ]Distinct Substrings 求不同子串数量 统计每个点有效的字符串数量(第一次出现的) \(\sum\limits_{now=1}^{nod}now.longest-paren ...
- SPOJ 694. Distinct Substrings (后缀数组不相同的子串的个数)转
694. Distinct Substrings Problem code: DISUBSTR Given a string, we need to find the total number o ...
- SPOJ 694 Distinct Substrings
Distinct Substrings Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on SPOJ. O ...
- 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 ...
- SPOJ 705 Distinct Substrings(后缀数组)
[题目链接] http://www.spoj.com/problems/SUBST1/ [题目大意] 给出一个串,求出不相同的子串的个数. [题解] 对原串做一遍后缀数组,按照后缀的名次进行遍历, 每 ...
随机推荐
- verilog中wire与reg类型的区别
每次写verilog代码时都会考虑把一个变量是设置为wire类型还是reg类型,因此把网上找到的一些关于这方面的资料整理了一下,方便以后查找. wire表示直通,即只要输入有变化,输出马上无条件地反映 ...
- DevExpress GridControl 的数据绑定
本人不才啊,折腾2个多小时才把数据绑定好.现在把折腾过程记录一下来以帮助更多的朋友,自己也温习一下. 直接上代码了哈.... WPF哈 xaml文件 <dxg:GridControl Name= ...
- Python版飞机大战
前面学了java用java写了飞机大战这次学完python基础后写了个python版的飞机大战,有兴趣的可以看下. 父类是飞行物类是所有对象的父类,setting里面是需要加载的图片,你可以换称自己的 ...
- 国内能用的NTP服务器及和标准源的偏差值
中国境内可以使用的NTP服务器的IP地址,和泰福特服务器的时间偏差值,泰福特时钟服务器实时连接天线,测试前已经连接天线超过72小时 time-a.nist.gov 129.6.15.28 NIST, ...
- 洛谷P2458 保安站岗
传送门啦 分析: 树形dp刚刚入门,这是我做的第一个一个点同时受父亲节点和儿子节点控制的题目. 由于这个题中某一个点放不放保安与父亲和儿子都有关系(因为线段的两个端点嘛),所以我们做题时就要考虑全面. ...
- 我常用的 Python 调试工具 - 博客 - 伯乐在线
.ckrating_highly_rated {background-color:#FFFFCC !important;} .ckrating_poorly_rated {opacity:0.6;fi ...
- Jmeter的接口测试简介
一.安装Jmeter Jmeter官方首页:http://jmeter.apache. ...
- jmock2.5 基本教程
目录 第0章 概述 第1章 jmock初体验 第2章 期望 第3章 返回值 第4章 参数匹配 第5章 指定方法调用次数 第6章 指定执行序列 第7章 状态机 第0章 概述 现在的dev不是仅仅要写co ...
- **iOS发JSON请求中字符串加转义,返回的JSON去转义
iOS中使用NSSerialization把对象转为JSON字符串后,多出来反斜杠的问题 http://segmentfault.com/q/1010000000576646 NSDictionary ...
- 动态页面技术JSP/EL/JSTL
本节内容: jsp脚本和注释 jsp运行原理 jsp指令(3个) jsp内置/隐式对象(9个) jsp标签(动作) EL技术 JSTL技术 JavaEE的开发模式 动态页面技术:就是在html中嵌入j ...