为什么
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
LL a, b, x, y, d;
LL exgcd(LL a, LL b, LL &x, LL &y){
if(!b){
x = 1, y = 0;
return a;
}
LL d = exgcd(b, a % b, y, x);
y -= a / b * x;
return d;
}
int main(){
while(~scanf("%lld%lld", &a, &b)){
d = exgcd(a, b, x, y);
//if(x > y) swap(x, y);
printf("%lld %lld %lld\n", x, y, d);
}
return 0;
}
能过
但
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
LL a, b, x, y, d;
LL exgcd(LL a, LL b, LL &x, LL &y){
if(!b){
x = 1, y = 0;
return a;
}
LL d = exgcd(b, a % b, y, x);
y -= a / b * x;
return d;
}
int main(){
while(~scanf("%lld%lld", &a, &b)){
d = exgcd(a, b, x, y);
if(x > y) swap(x, y);
printf("%lld %lld %lld\n", x, y, d);
}
return 0;
}
会WA啊