(2018 Multi-University Training Contest 3)Problem D. Euler Function


//题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6322
//题目大意:给定 k,求第 k 小的数 n,满足 φ(n) 是合数。显然 φ(1) = 1 不是合数,只考虑 n ≥ 2 的情况。
//思路:得到题意之后,查到了一张表(https://en.wikipedia.org/wiki/Euler%27s_totient_function
//得知当且仅当 n = 1, 2, 3, 4, 6 时,φ(n) 不是合数。第1小的K值是5,第二小的K值是7,第n(n>=3)小则是n+5;

AC代码:
 1 #include <bits/stdc++.h>
 2 using namespace std; 
 3 int main()
 4 {
 5     int T;
 6     scanf("%d",&T);
 7     while(T--)
 8     {
 9         int n;
10         scanf("%d",&n);
11         if(n==1)
12         cout<<5<<endl;
13         else if(n==2)
14         cout<<7<<endl;
15         else
16         {
17             cout<<n+5<<endl;
18         }
19     }
20 }
原文地址:https://www.cnblogs.com/lino/p/9392609.html