2018HDU多校训练-3-Problem D. Euler Function

Posted songorz

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2018HDU多校训练-3-Problem D. Euler Function相关的知识,希望对你有一定的参考价值。

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

Problem Description
In number theory, Euler‘s totient function φ(n)技术分享图片 counts the positive integers up to a given integer n技术分享图片 that are relatively prime to n技术分享图片 . It can be defined more formally as the number of integers k技术分享图片 in the range 1kn技术分享图片 for which the greatest common divisor gcd(n,k)技术分享图片 is equal to 1技术分享图片 .
For example, φ(9)=6技术分享图片 because 1,2,4,5,7技术分享图片 and 8技术分享图片 are coprime with 9技术分享图片 . As another example, φ(1)=1技术分享图片 since for n=1技术分享图片 the only integer in the range from 1技术分享图片 to n技术分享图片 is 1技术分享图片 itself, and gcd(1,1)=1技术分享图片 .
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 1技术分享图片 and itself. So obviously 1技术分享图片 and all prime numbers are not composite number.
In this problem, given integer k技术分享图片 , your task is to find the k技术分享图片 -th smallest positive integer n技术分享图片 , that φ(n)技术分享图片 is a composite number.
 
Input
The first line of the input contains an integer T(1T100000)技术分享图片 , denoting the number of test cases.
In each test case, there is only one integer k(1k10技术分享图片9技术分享图片)技术分享图片 .
 
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;
}

  







以上是关于2018HDU多校训练-3-Problem D. Euler Function的主要内容,如果未能解决你的问题,请参考以下文章

2018HDU多校训练-3-Problem F. Grab The Tree

[Lyndon分解] HDU 6761 Minimum Index (2020多校训练)

hdu 4911 Inversion(归并排序求逆序对数)2014多校训练第5场

2019HDU多校训练第五场1007-permutation 2

多校训练2HDU 6047 Maximum Sequence

HDU6621 K-th Closest Distance HDU2019多校训练第四场 1008(主席树+二分)