数论
SandraOvO
这个作者很懒,什么都没留下…
展开
-
欧几里德与扩展欧几里德算法
欧几里德算法(辗转相除法) 可用于计算两个整数a,b的公约数和公倍数 定理:gcd(a, b) = gcd(b , a%b) int gcd(int a,int b) { return b ? gcd(b,a%b):a; } 最小公倍数是: a*b/gcd(a,b) 不过我们为了防止a*b的溢出 采取先除后乘 a/gcd(a,b)*b 扩展欧几里德算法 基本算法:对于不完原创 2016-06-27 21:58:21 · 207 阅读 · 0 评论 -
A/B(乘法逆元)
A/B Description 要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1)。 Input 数据的第一行是一个T,表示有T组数据。 每组数据有两个数n(0 Output 对应每组数据输出(A/B)%9973。原创 2016-06-27 22:25:08 · 461 阅读 · 0 评论 -
POJ 2262 Goldbach's Conjecture(素数)
Description In 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in which he made the following conjecture: Every even number greater than 4 can be wri原创 2016-06-27 22:28:51 · 270 阅读 · 0 评论 -
HDU 1222 Wolf and Rabbit(gcd)
Description There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must hide in one of the holes. A wolf searches the rabbit in anticlockwise order. The first h原创 2016-06-27 22:30:28 · 371 阅读 · 0 评论 -
COJ 1010 [001]质因数分解 [EASY]
[001]质因数分解 [EASY] Time Limit: 1000 ms Memory Limit: 65536 KB Total Submit: 1891 Accepted: 582 Description 找出输入整数的所有质因数(包括重复质因数),并按从小到大的顺序依次输出。 Input 输入一组待分解整数,每个整数k占一行。原创 2016-06-24 10:09:43 · 1008 阅读 · 0 评论