ACM模版

## 題解

(a, b) -> (b, a) ··············································(1)
if (a, b) -> (x, y) to (x, y) -> (a, b) ··········(2)

(a, b) -> (a - b, b) -> (a - 2b, b) -> … -> (a - nb, b) 其中，n = a / b
(a, b) - > (a % b, b) -> (b, a % b)

## 代碼

``#include <iostream>#include <algorithm>#include <cstdio>#include <cmath>typedef long long ll;using namespace std;ll kgcd(ll a, ll b){    if (!a)    {        return b;    }    else if (!b)    {        return a;    }    else if (!(a & 1) && !(b & 1))    {        return kgcd(a >> 1, b >> 1) << 1;    }    else if (!(b & 1))    {        return kgcd(a, b >> 1);    }    else if (!(a & 1))    {        return kgcd(a >> 1, b);    }    else    {        return kgcd(abs(a - b), min(a, b));    }}int main(int argc, const char * argv[]){    int T;    cin >> T;    ll a, b, x, y;    while (T--)    {// scanf("%lld %lld %lld %lld", &a, &b, &x, &y);        cin >> a >> b >> x >> y;        if (kgcd(a, b) == kgcd(x, y))        {            printf("Yes\n");        }        else        {            printf("No\n");        }    }    return 0;}``

《GCD》