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/ [题目大意] 给出一个串,求出不相同的子串的个数. [题解] 对原串做一遍后缀数组,按照后缀的名次进行遍历, 每 ...
随机推荐
- bzoj 1607 Patting Heads 轻拍牛头
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1607 题解: 题目似乎出错,应为“同时拍打所有所持纸条上的数字能被此牛所持纸条上的数字整除 ...
- Failed to load class "org.slf4j.impl.StaticLoggerBinder"
调试程序出现如下错误: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".SLF4J: Default ...
- 练习题 --- 写出5种css定位语法
写出至少5种css语法(每种语法不一样)
- 20165203 学习基础和C语言基础调查
一.技能学习经验及体会 对于课外技能来说,我对很多领域都略知一二,但涉足不深,例如体育领域.摄影领域.绘画领域.书法领域等等,我所能拿得出手的就是体育领域的乒乓球了.娄老师的作业题目让我的思绪又回到了 ...
- 20155225 2016-2017-2 《Java程序设计》第十周学习总结
20155225 2016-2017-2 <Java程序设计>第十周学习总结 教材学习内容总结 22章网络 22.1网络概览 22.2超文本传输协议(HTTP) 22.2.1 HTTP请求 ...
- windows环境下的heap spray+stack pivot gadget 实现绕过dep
ASLR+DEP是windows平台下最为常见的两种保护手段.这两种手段使得最基础的jmp esp等手法不再适用,而单纯的堆喷也会因为堆内存不可执行而失效.那么这里就来介绍一下heap spray+s ...
- Elasticsearch 6.x 入门测试
首先听一下官方的话: https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html 我尝试了使用Java作为Cl ...
- WeifenLuo.WinFormsUI.Docking"的使用
要用 WeifenLuo.WinFormsUI.Docking 首先要下载: WeifenLuo.WinFormsUI.Docking 在当前工程“解决方案 - 引用”中 >> 右击引用 ...
- C#重写ToString
C# 中的每个类或结构都可隐式继承 <xref:System.Object> 类. 因此,C# 中的每个对象都会获取 <xref:System.Object.ToString%2A& ...
- 微信接口问题(The underlying connection was closed: An unexpected error occurred on a send)
突然在调用微信接口是报:The underlying connection was closed: An unexpected error occurred on a send错误,跟踪了半天,是因为 ...