开始系统的学习容斥原理!通常我们求1~n中与n互质的数的个数都是用欧拉函数! 但如果n比较大或者是求1~m中与n互质的数的个数等等问题,要想时间效率高的话还是用容斥原理! 本题是求[a,b]中与n互质的数的个数,可以转换成求[1,b]中与n互质的数个数减去[1,a-1]与n互质的数的个数。 #inc ...
分类:
其他好文 时间:
2017-02-02 16:37:26
阅读次数:
216
1简介 1简介 φ函数的值 通式:φ(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)就是1本身)。 (注意:每种质因数只一个。比如12=2*2*3 ...
分类:
其他好文 时间:
2017-02-01 20:56:45
阅读次数:
242
Problem Description The Euler function phi is an important kind of function in number theory, (n) represents the amount of the numbers which are small... ...
分类:
其他好文 时间:
2017-01-14 19:03:10
阅读次数:
219
直接两重循环O(n^2)算gcd……未免太耗时 枚举因数a和a的倍数n,考虑gcd(i,n)==a的i数量(i<=n) 由于gcd(i,n)==a等价于gcd(i/a,n/a)==1,所以满足gcd(i,n)==a的数有phi[n/a]个 打出欧拉函数表,枚举因数,计算出每个n的f[n]=gcd(1 ...
分类:
其他好文 时间:
2017-01-13 00:29:58
阅读次数:
236
题目链接: 1239:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1239 1244:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1244 ...
分类:
其他好文 时间:
2017-01-11 08:17:41
阅读次数:
277
void Euler_Sieve_Method(int * euler, int n) { euler[1] = 1; for (int i = 2; i < n; i++) { euler[i] = i; } for (int i = 2; i < n; i++) { if (euler[i] = ...
分类:
其他好文 时间:
2017-01-05 23:57:46
阅读次数:
380
这道题是欧拉函数的使用,这里简要介绍下欧拉函数。 欧拉函数定义为:对于正整数n,欧拉函数是指不超过n且与n互质的正整数的个数。 欧拉函数的性质:1.设n = p1a1p2a2p3a3p4a4...pkak为正整数n的素数幂分解,那么φ(n) = n·(1-1/p1)·(1-1/p2)·(1-1/p3 ...
分类:
其他好文 时间:
2017-01-03 22:04:42
阅读次数:
223
The Euler function Problem Description The Euler function phi is an important kind of function in number theory, (n) represents the amount of the numb ...
分类:
其他好文 时间:
2016-12-29 19:29:30
阅读次数:
181
题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1135 题意:中文题诶~ 思路:设m是正整数,a是整数,若a模m的阶等于φ(m),则称a为模m的一个原根。(其中φ(m)表示m的欧拉函数)给出1个质数P,找出P最 ...
分类:
其他好文 时间:
2016-12-25 18:29:50
阅读次数:
174
1968: [Ahoi2005]COMMON 约数研究 Description Input 只有一行一个整数 N(0 < N < 1000000)。 Output 只有一行输出,为整数M,即f(1)到f(N)的累加和。 Sample Input 3 Sample Output 5 HINT Sour ...
分类:
其他好文 时间:
2016-12-23 22:52:14
阅读次数:
200