博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 1787 GCD Again (欧拉函数)
阅读量:6229 次
发布时间:2019-06-21

本文共 1947 字,大约阅读时间需要 6 分钟。

GCD Again

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 2257    Accepted Submission(s): 908

Problem Description
Do you have spent some time to think and try to solve those unsolved problem after one ACM contest?
No? Oh, you must do this when you want to become a "Big Cattle".
Now you will find that this problem is so familiar:
The greatest common divisor GCD (a, b) of two positive integers a and b, sometimes written (a, b), is the largest divisor common to a and b. For example, (1, 2) =1, (12, 18) =6. (a, b) can be easily found by the Euclidean algorithm. Now I am considering a little more difficult problem: 
Given an integer N, please count the number of the integers M (0<M<N) which satisfies (N,M)>1.
This is a simple version of problem “GCD” which you have done in a contest recently,so I name this problem “GCD Again”.If you cannot solve it still,please take a good think about your method of study.
Good Luck!
 

 

Input
Input contains multiple test cases. Each test case contains an integers N (1<N<100000000). A test case containing 0 terminates the input and this test case is not to be processed.
 

 

Output
For each integers N you should output the number of integers M in one line, and with one line of output for each line in input. 
 

 

Sample Input
2
4
0
 

 

Sample Output
0
1
 

 

Author
lcy
 

 

Source
 

 

Recommend
lcy   |   We have carefully selected several similar problems for you:            

 

 模板题:

 

1 //0MS    200K    399 B    G++ 2 #include
3 int euler(int n) 4 { 5 int ret=1; 6 for(int i=2;i*i<=n;i++){ 7 if(n%i==0){ 8 n/=i;ret*=i-1; 9 while(n%i==0){10 n/=i;ret*=i;11 }12 }13 }14 if(n>1) ret*=n-1;15 return ret;16 }17 int main(void)18 {19 int n;20 while(scanf("%d",&n),n)21 {22 printf("%d\n",n-euler(n)-1);23 }24 return 0;25 }

 

 

转载于:https://www.cnblogs.com/GO-NO-1/p/3651687.html

你可能感兴趣的文章
python md5
查看>>
强制转换与内存
查看>>
发送UDP应答包的思考
查看>>
ASA防火墙基本配置
查看>>
软文真的可以帮助我们的网站吗?
查看>>
现代程序设计 作业6 - 简单而有意义的题目
查看>>
70、MSTP简介
查看>>
【VMware虚拟化解决方案】构建VMware私有云 实现ITaaS
查看>>
每天一个linux命令-mkdir
查看>>
四天精通shell编程(二)
查看>>
Linux 学习笔记_8_进程管理_2_进程管理命令
查看>>
python3中实现客户端与服务端交互发送文件
查看>>
Centos yum异常问题
查看>>
标签制作软件中如何导出标签模板为PDF文件?
查看>>
时间戳
查看>>
Jenkins的安装过程(Windows)
查看>>
程序员面试-程序设计基本概念(1)
查看>>
性能测试、负载测试、压力测试的区别
查看>>
html iframe高度自适应
查看>>
Flash Stage3D 在2D UI 界面上显示3D模型问题完美解决
查看>>