hdu 2654(欧拉函数)】的更多相关文章

Become A Hero Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 210    Accepted Submission(s): 57 Problem Description Lemon wants to be a hero since he was a child. Recently he is reading a book…
http://acm.hdu.edu.cn/showproblem.php?pid=6390 题意:求一个式子 题解:看题解,写代码 第一行就看不出来,后面的sigma公式也不会化简.mobius也不会 就自己写了个容斥搞一下(才能维持现在的生活) //别人的题解https://blog.csdn.net/luyehao1/article/details/81672837 #include <iostream> #include <cstdio> #include <cstr…
The Euler function Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5235    Accepted Submission(s): 2225 Problem Description The Euler function phi is an important kind of function in number theo…
2^x mod n = 1 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 15810    Accepted Submission(s): 4914 Problem Description Give a number n, find the minimum x(x>0) that satisfies 2^x mod n = 1.   I…
Description has only two Sentences Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1071    Accepted Submission(s): 323 Problem Description an = X*an-1 + Y and Y mod (X-1) = 0.Your task is to cal…
题意: 求出来区间[1,n]内与n互质的数的数量 题解: 典型的欧拉函数应用,具体见这里:Relatives POJ - 2407 欧拉函数 代码: 1 #include<stdio.h> 2 #include<string.h> 3 #include<iostream> 4 #include<algorithm> 5 #include<math.h> 6 using namespace std; 7 typedef long long ll;…
裸题 O(nlogn): #include <cstdio> #include <iostream> #include <algorithm> using namespace std; typedef long long ll; const int maxn=3000000+100; int phi[maxn]; void init() { for(int i=2;i<maxn;i++) phi[i]=i; for(int i=2;i<maxn;i++) i…
http://acm.hdu.edu.cn/showproblem.php?pid=4983 求有多少对元组满足题目中的公式. 对于K=1的情况,等价于gcd(A, N) * gcd(B, N) = N,我们枚举 gcd(A, N) = g,那么gcd(B, N) = N / g.问题转化为统计满足 gcd(A, N) = g 的 A 的个数.这个答案就是 ɸ(N/g) 只要枚举 N 的 约数就可以了.答案是 Σɸ(N/g)*ɸ(g) g | N 暴力即可 #include <cstdio>…
题意:求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是不为0的整数.φ(1)=1(唯一和1互质的数就是1本身). 因此含质因数最多的即为所求,打表求出前n个积,之后找到比自己小的最大积 大数打表 2015-07-27:到此一游 #include<cstdio> #include<iostream> #include<algorith…
GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2874    Accepted Submission(s): 1240 Problem Description Do you have spent some time to think and try to solve those unsolved problem af…