随笔分类 - 数论
摘要:Product Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Problem Description Given a number sequence A1,A2....An,ind
阅读全文
摘要:E. Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bizon the Champion isn't jus
阅读全文
摘要:1694: Primorial vs LCM 题目描述 Given N (2<=N<=10^14), what is the quotient of LCM(1,2,3,....,N) divided by multiple of all primes up to N. As the result
阅读全文
摘要:判断一个素数是否为素数: 1:2-n-1。。。for暴力判断; 2:sqrt(n) 判断; 3:一个我也不知道为什么的代码,总之蛮快的 4:判断一个大素数的米勒拉宾素数测试 复杂度:O(k*log(n))k是测试的次数 素数打表: 1 埃拉特斯特尼筛法复杂度O(n loglog(n)); 2 欧拉筛
阅读全文
摘要:首先需要知道两个定理: 1: 费马小定理: 假如p是素数,且gcd(a,p)=1,那么 a(p-1)≡1(mod p)。 2:二次探测定理:如果p是素数,x是小于p的正整数,且,那么要么x=1,要么x=p-1。 证明:这是显然的,因为相当于p能整除,也即p能整除(x+1)(x-1)。 由于p是素数,
阅读全文
摘要:首先,要知道欧拉函数是什么!!! 欧拉函数是小于n的数中与n互质(最大公约数为1)的数的数目; 然后,你需要想想 若n是质数p的k次幂, ,因为除了p的倍数外,其他数都跟n互质。 可得 若 则 代码: int phi(int n) { int i,rea=n; for(i=2;i*i<=n;i++)
阅读全文
摘要:phi(c)为欧拉函数, 欧拉定理 : 对于互质的正整数 a 和 n ,有 aφ(n) ≡ 1 mod n 。 A^x = A^(x % Phi(C) + Phi(C)) (mod C) (x >= phi(C))
阅读全文
摘要:C. Monitor time limit per test 0.5 second memory limit per test 64 megabytes input standard input output standard output C. Monitor time limit per tes
阅读全文
摘要:Chinese remainder theorem again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description 我知道部分同学最近在看中国剩余定理
阅读全文
摘要:若ax≡1 mod f, 则称a关于模f的乘法逆元为x。也可表示为ax≡1(mod f)。 当a与f互素时,a关于模f的乘法逆元有唯一解。如果不互素,则无解。如果f为素数,则从1到f-1的任意数都与f互素,即在1到f-1之间都恰好有一个关于模f的乘法逆元。 (不会证明,想通了补) 首先a与f要互素,
阅读全文
摘要:摘取于http://blog.csdn.net/kenden23/article/details/37519883; 找到规律之后本题就是水题了,不过找规律也不太容易的,证明这个规律成立更加不容易。 本题就是求step和mod如果GCD(最大公约数位1)那么就是Good Choice,否则为Bad
阅读全文
摘要:定理:对于不完全为 0 的非负整数 a,b,gcd(a,b)表示 a,b 的最大公约数,必然存在无数组整 数对 x,y ,使得 gcd(a,b)=ax+by。 证明: 求解 x,y的方法的理解 设 a>b。 1,显然当 b=0,gcd(a,b)=a。此时 x=1,y=0; 2,a>b>0 时 设 a
阅读全文
摘要:定理:两个整数的最大公约数等于其中较小的那个数和两数的相除余数的最大公约数。最大公约数(greatest common divisor)缩写为gcd。 gcd(a,b) = gcd(b,a mod b) (不妨设a>b 且r=a mod b ,r不为0) 定理:两个整数的最大公约数等于其中较小的那个
阅读全文