链接:http://acm.hdu.edu.cn/showproblem.php?pid=6322

Problem Description
In number theory, Euler's totient function because and are coprime with . As another example, since for the only integer in the range from to is itself, and .
A composite number is a positive integer that can be formed by multiplying together two smaller positive integers. Equivalently, it is a positive integer that has at least one divisor other than and itself. So obviously and all prime numbers are not composite number.
In this problem, given integer , your task is to find the -th smallest positive integer , that is a composite number.
 
Input
The first line of the input contains an integer , denoting the number of test cases.
In each test case, there is only one integer .
 
Output
For each test case, print a single line containing an integer, denoting the answer.
 
Sample Input
2 1 2
 

 

Sample Output
5 7
 

 

Source
 

 

Recommend
chendu   |   We have carefully selected several similar problems for you:  6331 6330 6329 6328 6327 
题解:给你一个数k,让你求让你求第k 个gcd(num,x)的个数为合数(除了1)的num,x为从1 ~ num-1,这题题名写着欧拉函数,很明显让你求第k个欧拉函数值为合数的数;
显然,由于大于3的质数都满足题意(根据欧拉函数知道,质数的欧拉函数值为x-1,必为大于2的偶数)
对于奇数: 有当m,n互质时,有f(mn)=f(m)f(n),根据任何数都可以由多个质数的多少次幂相乘得到,故,对于质数num,其可以由一个质数乘另一个数得到,质数和任意数都是互质的,故f(num)=f(x)f(y){假设x为质数},则,f(num)=(x-1)*f(y),由(x-1)为偶数,且f(y)>1,则对于任意奇数都是满足题意的;
对于偶数:由上同理可以推出只有6不满足题意:故只要排除6即可;从4开始遍历:
参考代码为:
#include<bits/stdc++.h>
using namespace std;

int main()
{
	int t;
	long long k;
	cin>>t;
	while(t--)
	{
		cin>>k;
		if(k==1) cout<<5<<endl;
		else cout<<k+5<<endl;
	}
	return 0;
}

  

相关文章: