标签:
Description
Input
Output
Sample Input
Sample Output
#include<iostream> using namespace std; void gcd(int a,int b,int &d,int &x,int &y){ if(!b){d=a;x=1;y=0;} else { gcd(b,a%b,d,y,x); y-=x*(a/b); } } int main(){ int a,b,d,x,y; while(cin>>a>>b){ gcd(a,b,d,x,y); if(d!=1)cout<<"sorry"<<endl; else { while(x<0){ x+=b; y-=a; } cout<<x<<" "<<y<<endl; } } return 0; }
标签:
原文地址:http://www.cnblogs.com/demodemo/p/4749066.html