链接: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 1≤k≤n 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(1≤T≤100000)

, denoting the number of test cases.
In each test case, there is only one integer k(1≤k≤109)

.

 
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的更多相关文章

  1. HDU 6322.Problem D. Euler Function -欧拉函数水题(假的数论题 ̄▽ ̄) (2018 Multi-University Training Contest 3 1004)

    6322.Problem D. Euler Function 题意就是找欧拉函数为合数的第n个数是什么. 欧拉函数从1到50打个表,发现规律,然后勇敢的水一下就过了. 官方题解: 代码: //1004 ...

  2. 2018HDU多校训练-3-Problem M. Walking Plan

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=6331 Walking Plan  Problem Description There are n inte ...

  3. 2018HDU多校训练-3-Problem G. Interstellar Travel

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=6325                                   Interstellar Tra ...

  4. 2018HDU多校训练一 K - Time Zone

    Chiaki often participates in international competitive programming contests. The time zone becomes a ...

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

    Little Q and Little T are playing a game on a tree. There are n vertices on the tree, labeled by 1,2 ...

  6. 2018HDU多校训练一 D Distinct Values

    hiaki has an array of nn positive integers. You are told some facts about the array: for every two e ...

  7. 2018HDU多校训练一 C -Triangle Partition

    Chiaki has 3n3n points p1,p2,-,p3np1,p2,-,p3n. It is guaranteed that no three points are collinear.  ...

  8. 2018HDU多校训练一 A - Maximum Multiple

    Given an integer nn, Chiaki would like to find three positive integers xx, yy and zzsuch that: n=x+y ...

  9. (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 ...

随机推荐

  1. 云服务器linux系统修改时间和时区

    申请的云服务器时间不对,用同步网络时间的命令执行后依然有问题. 解决办法: # tzselect [root@ylyuat2-web02 logs]# TZ='Asia/Shanghai'[root@ ...

  2. 力扣(LeetCode)验证回文串 个人题解

    给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写. 说明:本题中,我们将空字符串定义为有效的回文串. 示例 1: 输入: "A man, a plan, a c ...

  3. Vue_声明周期

    Vue生命周期 在vue2.0的时候,声明钩子发生了改变,具体有八个 <!-- HTML部分 --> <div id="app"> <div>{ ...

  4. 性能测试专题:Locust工具实战之“蝗虫”降世

    阅读全文需5分钟. 1. 前言 在上一篇文章中,我们已经为大家介绍了什么是Locust,具体可参照:性能专题:Locust工具实战之开篇哲学三问,简单来说,Locust 是基于 Python 语言下的 ...

  5. 2019-11-7:sql注入防御,webshell概念,学习笔记

    sql注入防护GPC,magic_quotes_gpc函数在php中的作用是判断解析用户提示的数据,如包括有:post.get.cookie过来的数据增加转义字符“\”,以确保这些数据不会引起程序,特 ...

  6. 为什么阿里巴巴Java开发手册中强制要求不要在foreach循环里进行元素的remove和add操作?

    在阅读<阿里巴巴Java开发手册>时,发现有一条关于在 foreach 循环里进行元素的 remove/add 操作的规约,具体内容如下: 错误演示 我们首先在 IDEA 中编写一个在 f ...

  7. Head First设计模式——模板方法模式

    前言:本篇我们讲解模板方法模式,我们以咖啡和茶的冲泡来学习模板方法.关于咖啡另一个设计模式例子也以咖啡来讲解,可以看下:Head First设计模式——装饰者模式 废话不多说,开始进入模板方法模式. ...

  8. .NET Core 跨平台 GUI 开发之 GTtkSharp 初级篇

    .NET Core 跨平台 GUI 开发之 GTtkSharp 初级篇 本文作为初级篇,适合已经安装好.NET Core 环境以及 Gtk 环境,并具备了 C#开发基础知识,能跑一些简单的例子,希望更 ...

  9. Spring Boot中使用Jpa的findOne方法不能传入id

    最近通过慕课网学习spring boot,视频中通过jpa的findOne方法以id为参数查询出对应的信息, 而当我自己做测试的时候却发现我的findOne方法的参数没有Integer类型的id,而是 ...

  10. Python中的Base64编码的加密与解密

    Base64 可以干些啥? Base64编码的作用: 由于某些系统中只能使用ASCII字符.Base64就是用来将非ASCII字符的数据转换成ASCII字符的一种方法. 图片(and种子)base64 ...