#include#include #include #include using namespace std;int exgcd(int a,int b,int &x,int &y){ int r,tmp; if(!b){x=1;y=0;return a;} else{ r=exgcd(b,a%b,x,y); tmp=x; x=y; y=tmp-a/b*y; //printf("%d %d\n",x,y); return r; }} int main(){ int i,j,k,m,n,a,b,x,y,z; scanf("%d%d%d%d",&a,&b,&x,&y); z=exgcd(a,b,x,y); printf("%d %d %d",z,x,y); return 0;}