标签:class blog code ext 2014 name
已知 a,b (a>=0,b>=0)
求一组解 (x,y) 使得 (x,y)满足
gcd(a,b) = ax+by
注意求出的 x,y 可能为0或负数
代码中g = gcd(a,b);
ll extend_gcd (ll a , ll b , ll &x , ll &y) { if (b == 0) { x = 1LL; y = 0; return a; } ll g = extend_gcd (b , a % b , x , y); ll t = x; x = y; y = t - a / b * x; return g; }
标签:class blog code ext 2014 name
原文地址:http://blog.csdn.net/qq574857122/article/details/33001883