HDU 1787 GCD Again(欧拉函数,水题)
GCD Again
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1997 Accepted Submission(s): 772
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!
4
0
1
用来试验下模板。
求欧拉函数就可以了
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std; long long eular(long long n)
{
long long ans = n;
for(int i = ;i*i <= n;i++)
{
if(n % i == )
{
ans -= ans/i;
while(n % i == )
n /= i;
}
}
if(n > )ans -= ans/n;
return ans;
} int main()
{
int n;
while(scanf("%d",&n) == && n)
{
int ret = eular(n);
printf("%d\n",n-ret-);
}
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 6322.Problem D. Euler Function -欧拉函数水题(假的数论题 ̄▽ ̄) (2018 Multi-University Training Contest 3 1004)
6322.Problem D. Euler Function 题意就是找欧拉函数为合数的第n个数是什么. 欧拉函数从1到50打个表,发现规律,然后勇敢的水一下就过了. 官方题解: 代码: //1004 ...
- 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-1286 找新朋友(欧拉函数,水题)
题目链接: 找新朋友 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
随机推荐
- [Android教程]EditText设置/隐藏光标位置、选中文本和获取/清除焦点
有时候需要让光标显示在EditText的指定位置或者选中某些文本.同样,为了方便用户输入以提升用户体验,可能需要使EditText获得或失去焦点. 1. 设置光标到指定位置 EditText et ...
- 【笨嘴拙舌WINDOWS】BMP图片浏览器
要将文件显示成图片这其中需要经过 1.将磁盘文件内容读取到内存: 2.将文件对应内存里包含的像素为以及像素信息转化为显示驱动器能理解的格式: 3.将转化过后的内存送到显卡的缓存区 4.显示器读取缓存现 ...
- 【笨嘴拙舌WINDOWS】设备无关图(*.bmp)
设备无关图在windows上面就是一个扩展名为.bmp的文件.我们知道每一种文件都是一个二进制流,只是这个二进制流的开头几个字节是规定了文件的格式..bmp的文件格式如下 “其中信息头是windows ...
- HDU 2084 数塔
没什么好说的,这是我学DP的第一道题目. //#define LOCAL #include <iostream> #include <cstdio> #include < ...
- mysql连接超时
这几天在跟踪一个项目的时候,老是发现mysql连接报timeout的异常. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException ...
- 【英语】Bingo口语笔记(59) - 穿着的表达
- T-SQL备忘(3):分组合并
--CREATE TABLE test(code varchar(50), [name] varchar(10),[count] int ) --INSERT test SELECT '001' , ...
- Linux/Unix shell 监控Oracle实例(monitor instance)
使用shell脚本实现对Oracle数据库的监控与管理将大大简化DBA的工作负担,如常见的对实例的监控,监听的监控,告警日志的监控,以及数据库的备份,AWR report的自动邮件等.本文给出Linu ...
- android adt自带eclipse无法设置ndk路径(找不到NDK配置)
分步阅读 到android sdk官网下载r23版本的adt时自带的eclipse没有设置ndk路径的地方,通过Install New Software 发现无法更新,那么如何解决这个问题呢? 方便他 ...
- JBPM4入门——9.自动节点单线执行
JBPM入门系列文章: JBPM4入门——1.jbpm简要介绍 JBPM4入门——2.在eclipse中安装绘制jbpm流程图的插件 JBPM4入门——3.JBPM4开发环境的搭建 JBPM4入门—— ...