hdu 1787(欧拉函数)
GCD Again
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2874 Accepted Submission(s): 1240
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!
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.
4
0
1
#include <stdio.h>
#include <string.h>
using namespace std;
typedef long long LL;
LL phi(LL x)
{
LL ans=x;
for(LL i=; i*i<=x; i++)
if(x%i==)
{
ans=ans/i*(i-);
while(x%i==) x/=i;
}
if(x>)
ans=ans/x*(x-);
return ans;
} int main(){
LL n;
while(scanf("%lld",&n)!=EOF,n){
printf("%lld\n",n-phi(n)-);
}
}
hdu 1787(欧拉函数)的更多相关文章
- hdu 6390 欧拉函数+容斥(莫比乌斯函数) GuGuFishtion
http://acm.hdu.edu.cn/showproblem.php?pid=6390 题意:求一个式子 题解:看题解,写代码 第一行就看不出来,后面的sigma公式也不会化简.mobius也不 ...
- hdu 2654(欧拉函数)
Become A Hero Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- hdu 2824(欧拉函数)
The Euler function Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- hdu 1395(欧拉函数)
2^x mod n = 1 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- hdu 3307(欧拉函数+好题)
Description has only two Sentences Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/327 ...
- 找新朋友 HDU - 1286 欧拉函数模板题
题意: 求出来区间[1,n]内与n互质的数的数量 题解: 典型的欧拉函数应用,具体见这里:Relatives POJ - 2407 欧拉函数 代码: 1 #include<stdio.h> ...
- hdu 2824 欧拉函数 O(nlogn) 和O(n)
裸题 O(nlogn): #include <cstdio> #include <iostream> #include <algorithm> using name ...
- hdu 4983 欧拉函数
http://acm.hdu.edu.cn/showproblem.php?pid=4983 求有多少对元组满足题目中的公式. 对于K=1的情况,等价于gcd(A, N) * gcd(B, N) = ...
- hdu 4002 欧拉函数 2011大连赛区网络赛B
题意:求1-n内最大的x/phi(x) 通式:φ(x)=x*(1-1/p1)*(1-1/p2)*(1-1/p3)*(1-1/p4)…..(1-1/pn),其中p1, p2……pn为x的所有质因数,x是 ...
随机推荐
- Python模块(二)(序列化)
1. namedtuple 命名元组->类似创建了一个类 from collections import namedtuple p = namedtuple("Point", ...
- 重新造轮子之静态链接2(Static linking)
有了上一篇的基础, 这次写一个我们已经滚瓜烂熟的C程序 helloworld .只不过这次我们不能用到到C语言中的main()函数. 实验环境: linux 编译器: gcc 编辑器:Vim 1. ...
- SMP IRQ Affinity
转:非常有用的方法,调式神器 SMP IRQ Affinity Background: Whenever a piece of hardware, such as disk controller or ...
- mac配置启动mongodb
1.新建文件夹,用于存放数据库文件.建议放在自己用户名的文件夹下,不需要sudo会方便很多. 在Users的自己用户名环境下: mkdir [文件夹名] 2.转到mongodb的Bin目录,执行mon ...
- dedecms 标签
article文章页标签 文档工具:http://tools.dedecms.com/dedetag_maker/article.html {dede:field.title/} 文章标题 {dede ...
- 【Linux】tcpdump命令详解
tcpdump可以将网络中传送的数据包的“头”完全截获下来提供分析. 它支持针对网络层.协议.主机.网络或端口的过滤,并提供and.or.not等逻辑语句帮你过滤到无用的信息. 实用命令实例 1.普通 ...
- [转] 彻底搞懂word-break、word-wrap、white-space
white-space.word-break.word-wrap(overflow-wrap)估计是css里最基本又最让人迷惑的三个属性了,我也是用了n次都经常搞混,必须系统整理一下,今天我们就把这三 ...
- luogu1262 间谍网络
贿赂所有能贿赂的,如果还有人不被访问则显然是NO. 否则,必定为YES.强联通分量缩成一个DAG,若某点的入度为零,则答案要算上它的. #include <iostream> #inclu ...
- [每日app二]月入60万多嘛?单词锁屏的潜力!
抢了用户的时间,就是抢了用户的金钱! 单词锁屏,一个开发难度不太大,但仅仅360手机助手下载就是每周4万!拉风- 对于搞app的同学来说,搞个锁屏,还不是玩似的,但是要定位好,玩得好,那就有难度了.最 ...
- [POJ 1001] Exponentiation C++解题报告 JAVA解题报告
Exponentiation Time Limit: 500MS Memory Limit: 10000K Total Submissions: 126980 Accepted: 30 ...