CF1152C. Neko does Maths

CF1152C
http://codeforces.com/contest/1152/problem/C

大意:给两个数a,b。让你找一个k,使得a+k与b+k的最小公倍数尽可能小,输出k
思路: gcd(a,b) = gcd(b,a-b),最终得到的A,B,他们的gcd一定是a-b的因子

#include 
using namespace std;

// gcd(a,b) = gcd(b,a-b); -> (a-b)%gcd(a,b)==0
long long a,b,diff;
vector v;
int main(){
    cin>>a>>b;
    if(a>b)swap(a,b);
    diff = b-a;

    if(diff==0){
        cout<<0<=a的因子,那么找diff的倍数直到>=a
    }
    cout<

你可能感兴趣的:(CF1152C. Neko does Maths)