hdu 1787 GCD Again (欧拉函数)
GCD Again
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2257 Accepted Submission(s): 908
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!
模板题:
//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 ;
}
hdu 1787 GCD Again (欧拉函数)的更多相关文章
- HDU 1787 GCD Again(欧拉函数,水题)
GCD Again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- HDU 1695 GCD (欧拉函数+容斥原理)
GCD Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- HDU 1695 GCD(欧拉函数+容斥原理)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1695 题意:x位于区间[a, b],y位于区间[c, d],求满足GCD(x, y) = k的(x, ...
- hdu 1695 GCD(欧拉函数+容斥)
Problem Description Given 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD( ...
- HDU 2588 GCD(欧拉函数)
GCD Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...
- 题解报告:hdu 2588 GCD(欧拉函数)
Description The greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written ...
- hdu 1695 GCD (欧拉函数、容斥原理)
GCD Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...
- hdu 4983 Goffi and GCD(欧拉函数)
Problem Description Goffi is doing his math homework and he finds an equality on his text book: gcd( ...
- (hdu step 7.2.2)GCD Again(欧拉函数的简单应用——求[1,n)中与n不互质的元素的个数)
题目: GCD Again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
随机推荐
- checkbox的第三种状态--不确定状态
视觉上,checkbox有三种状态:checked.unchecked.indeterminate(不确定的).看起来就像这样子:
- visual studio 2015密钥
Visual Studio Professional 2015简体中文版(专业版)KEY:HMGNV-WCYXV-X7G9W-YCX63-B98R2Visual Studio Enterprise 2 ...
- fabric Report API
1.Token生成 接口 : post https://fabric.io/oauth/token 请求头:Headers Content-Type : application/json 正文: bo ...
- ubuntu 18 lnmp
1安装Nginx sudo apt-get install nginx 2安装PHP sudo apt- php7.-fpm 3安装mysql sudo apt-get install mysql 启 ...
- hive 学习系列五(hive 和elasticsearch 的交互,很详细哦,我又来吹liubi了)
hive 操作elasticsearch 一,从hive 表格向elasticsearch 导入数据 1,首先,创建elasticsearch 索引,索引如下 curl -XPUT '10.81.17 ...
- Leecode刷题之旅-C语言/python-83删除排序链表中的重复元素
/* * @lc app=leetcode.cn id=83 lang=c * * [83] 删除排序链表中的重复元素 * * https://leetcode-cn.com/problems/rem ...
- 局域网访问不到linux下的tomcat
问题描述: CentOS安装完成Tomcat后,访问本地:http://localhost:8080/正确.但局域网内无法访问,而且服务器可ping通 经查原因为防火墙开启: [root@localh ...
- docker学习(一) 安装
一.什么是docker 参见https://baike.baidu.com/item/Docker/13344470?fr=aladdin 个人的理解是,通俗来说,就是相当于一个方便携带且个体独立的虚 ...
- 图表制作工具之ECharts
简介 ECharts,缩写来自Enterprise Charts,商业级数据图表,一个纯Javascript的图表库,可以流畅的运行在PC和移动设备上,兼容当前绝大部分浏览器(IE6/7/8/9/10 ...
- dfs Gym - 100989L
AbdelKader enjoys math. He feels very frustrated whenever he sees an incorrect equation and so he tr ...