HDU 6322 Euler Function(找规律)

题目链接:Euler Function

题意

输出第 k k 小的 ϕ(n) 为合数的 n n 的值,其中 ϕ(x) 为欧拉函数( ϕ(x) ϕ ( x ) 表示 i[1,x] i ∈ [ 1 , x ] gcd(i,x)=1 gcd ( i , x ) = 1 的数字个数)。

输入

第一行为一个整数 T (1T105) T   ( 1 ≤ T ≤ 10 5 ) ,接下去 T T 行每行一个整数 k (1k109)

输出

对于每一个 k k ,输出第 k 小的合法的数字。

样例

输入
2
1
2
输出
5
7
题解

通过打表找规律可以发现,除了 k=1 k = 1 时答案为 5 5 外,其他答案都为 k+5

过题代码

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define LL long long

int main() {
    #ifdef Dmaxiya
    freopen("test.txt", "r", stdin);
    #endif // Dmaxiya
    ios::sync_with_stdio(false);

    int T, k;
    scanf("%d", &T);
    while(T--) {
        scanf("%d", &k);
        if(k == 1) {
            printf("5\n");
        } else {
            printf("%d\n", k + 5);
        }
    }

    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值