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:  1788 1695 1573 1905 1299 

模板题:

 //0MS    200K    399 B    G++
#include<stdio.h>
int euler(int n)
{
int ret=;
for(int i=;i*i<=n;i++){
if(n%i==){
n/=i;ret*=i-;
while(n%i==){
n/=i;ret*=i;
}
}
}
if(n>) ret*=n-;
return ret;
}
int main(void)
{
int n;
while(scanf("%d",&n),n)
{
printf("%d\n",n-euler(n)-);
}
return ;
}

最新文章

  1. div盒子中子元素(子元素可能是盒子, 图片) 中居中的三种方法
  2. 【AT91SAM3S】串口UART初始化及收发数据
  3. java1.7集合源码阅读:LinkedList
  4. Entity Framework 5.0基础系列
  5. lazyload.js详解
  6. canvas API ,通俗的canvas基础知识(六)
  7. 如何在视频处理控件TVideoGrabber中设置音频捕捉设备
  8. Linux系统环境变量及命令
  9. app配置智能硬件的解决方案
  10. 抓取&ldquo;矢量&rdquo;的实时交通流量数据
  11. 解决Github使用Fastly CDN而导致不能加载网页的方法
  12. python爬取煎蛋图片
  13. CAN控制器-配置过滤器
  14. Order&amp;Shipping Transactions Status Summary
  15. RIPng(第三组)
  16. 机器学习---文本特征提取之词袋模型(Machine Learning Text Feature Extraction Bag of Words)
  17. 二分搜索-HihoCoder1128
  18. Shell学习之Shell特性(一)
  19. ServiceBase.OnStart 方法
  20. ipv6问题

热门文章

  1. python实践项目—Collatz序列
  2. 使用百度定位Api获取当前用户登录地址
  3. js获取播放器播放时间和停止播放
  4. Phpstrom开发工具
  5. Python3.X-文本编码问题
  6. 【Nginx一】Nginx服务器搭建
  7. 初识python 文件读取 保存
  8. ABAP CDS - Syntax
  9. Spring AOP(一)——基础概念
  10. NodeJS微信公众平台开发