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

题意:找第n个由至少三个不同素因子组成的数。

思路:n<=1000直接暴力打表预处理

/** @Date    : 2016-12-11-19.01
* @Author : Lweleth (SoungEarlf@gmail.com)
* @Link : https://github.com/
* @Version :
*/
#include<bits/stdc++.h>
#define LL long long
#define PII pair
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std; const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8; int pri[N];
int ans[10010];
int c = 0;
bool vis[N];
int prime()
{
MMF(vis);
for(int i = 2; i < N; i++)
{
if(!vis[i])
pri[c++] = i; for(int j = 0; j < c && pri[j]*i < N; j++)
{
vis[i * pri[j]] = 1;
if(i % pri[j] == 0)
break;
}
}
} int main()
{
prime();
int tot = 0;
for(int i = 0; i <= 10000; i++)
{
int t = i;
int cnt = 0;
for(int j = 0; j < c && pri[j]*pri[j] <= t; j++)
{
if(t % pri[j] == 0)
{
cnt++;
while(t % pri[j] == 0)
t /= pri[j];
}
}
if(t > 1)
cnt++;
if(cnt >= 3)
ans[tot++] = i;
}
int T;
scanf("%d", &T);
while(T--)
{
int n;
scanf("%d", &n);
printf("%d\n", ans[n - 1]);
}
return 0;
}

最新文章

  1. Create and Install Timer Job in MOSS 2007
  2. JavaWeb学习笔记——开发动态WEB资源(三)显示当前时间
  3. 忧桑三角形,调了半天,真忧桑TAT
  4. SQOOP Load Data from Oracle to Hive Table
  5. UIImage拉伸显示
  6. JSON基础知识
  7. 浅谈 qmake 之 shadow build(就是将源码路径和构建路径分开)
  8. C++中的继承详解(3)作用域与重定义,赋值兼容规则
  9. 最新spring官网(spring.io)下载方法
  10. 如何使用supervisor管理你的应用
  11. PHPCMS v9.6.0 wap模块 SQL注入
  12. eclipse 中git无法https下载提交代码
  13. Java Script 简介
  14. SSH三大框架的工作原理
  15. linux django 知识点 安装mysql数据库 和 pycharm
  16. C# 取form表单的数据
  17. __construct 与 __destruct 区别
  18. spring学习之一概念
  19. 【Python】动态获取python类名、函数名&amp;多线程
  20. Amazon - removed your selling privileges and placed a temporary hold on any funds - 1

热门文章

  1. Python中__name__属性的妙用
  2. postmortem report of period M2
  3. 第一次课堂作业---circle
  4. lintcode-182-删除数字
  5. 数据库性能优化之SQL优化
  6. s3c2440调试nandflash裸机程序遇到的问题
  7. week12 201621044079 流与文件
  8. linux的几个发行网站
  9. 第三部分shell编程3(shell脚本编写1)
  10. QT分析之QPushButton的初始化