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是 ...
随机推荐
- MySQL8.0.12安装及配置
一.下载 下载页面http://dev.mysql.com/downloads/mysql/ 选择系统平台后,点击download(根据系统选择64或32位) 二.配置 1.下载成功后,解压安装包到要 ...
- [图文] Fedora 28 使用 Virt-Manager 创建 KVM 虚拟机以及 配置 KVM 虚拟机
实验说明: 往后的许多实验都将以Linux平台下的 KVM虚拟机为主,所以不可少的就是 Virt-Manager 虚拟机管理器. 本章将对如何安装和使用Virt-Manager管理器进行讲解,并且会对 ...
- jQuery获取动态添加的元素,live和on的区别
今天给大家说一下如果用jQuery获取动态添加的元素,通常如果你在网页上利用jQuery添加一个元素,那么用平常的jQuery获取元素的方法无效的获取不到的.可以用以下的方法获取动态元素!假设我们现在 ...
- 在linux下安装并运行scrapyd
系统:centos7.4 安装scrapyd:pip isntall scrapyd 因为我腾讯云上是python2与python3并存的 所以我执行的命令是:pip3 isntall scrapyd ...
- init_bootmem_node
初始化pg_data_t->bdtat结构体, /* * node_bootmem_map is a map pointer - the bits represent all physical ...
- POJ:2109-Power of Cryptography(关于double的误差)
Power of Cryptography Time Limit: 1000MS Memory Limit: 30000K Description Current work in cryptograp ...
- 素数筛选:HDU2710-Max Factor
Max Factor Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem ...
- dict 字典的常用操作
#dict 字典的常用操作: id_db.get() #获取 id_db.update() #更新(覆盖)字典 id_db.values() #打印字典里所有的values id_db.keys() ...
- studio rendering problems
问题--------> Rendering Problems The following classes could not be instantiated: - android.support ...
- [转] babel-present-env 与 babel-polyfill 学习总结
babelrc 配置文件 { "presets": [ [ "env", { "modules": false, "useBuil ...