poj 1061 青蛙的约会()
时间:2014-06-07 07:50:13
收藏:0
阅读:187
题目链接
题意:
扩展gcd模板:
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #define LL long long 6 using namespace std; 7 8 void exgcd(LL a, LL b, LL &d, LL &x, LL &y) 9 { 10 if(!b) {d = a; x = 1; y = 0;} 11 else{ exgcd(b, a%b, d, y, x); y -= x*(a/b); } 12 } 13 int main() 14 { 15 LL a, b, d, x, y; 16 while(cin>>a>>b) 17 { 18 exgcd(a, b, d, x, y); 19 printf("%lld %lld %lld %lld %lld\n", a, x, b, y, d); 20 } 21 return 0; 22 }
评论(0)