题目描述: C. Neko does Maths time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher. N…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher. Neko has two integers a and b.…
Neko does MathsCodeForces - 1152C 题目大意:给两个正整数a,b,找到一个非负整数k使得,a+k和b+k的最小公倍数最小,如果有多个k使得最小公倍数最小的话,输出最小的k. 首先让b>a,由lcm(a,b)=a*b/gcd(a,b),可以得出如果b%a==0,那么它们的最小公倍数就是b,此时的k就等于0.但如果b%a!=0的话,我们设g=gcd(a+k,b+k),那么就是有a+k=q1*g,b+k=q2*g,两者做差,那么b-a=(q2-q1)*g,由此我们可以知…
数论 gcd 看到这个题其实知道应该是和(a+k)(b+k)/gcd(a+k,b+k)有关,但是之后推了半天,思路全无. 然而..有一个引理: gcd(a, b) = gcd(a, b - a) = gcd(b, b - a) (b > a) 证明一下: 令 gcd(a, b) = c, (b > a) 则有 a % c = 0, b % c = 0 那么 (a - b) % c = 0 令 gcd(a, b - a) = c', 假设c' != c 则有 a % c' = 0, (b - a…