zoukankan      html  css  js  c++  java
  • 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(1k109) .
     
    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;
    }
    

      

  • 相关阅读:
    读《暗时间》
    文献笔记8
    文献笔记4
    文献笔记2
    文献笔记5
    文献笔记6
    文献笔记1
    文献笔记3
    读《暗时间》2
    文献笔记7
  • 原文地址:https://www.cnblogs.com/csushl/p/9398398.html
Copyright © 2011-2022 走看看