Pagini recente » Cod sursa (job #2475714) | Cod sursa (job #2624876) | Profil Estiarte | Cod sursa (job #2793896) | Cod sursa (job #2006055)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int T,a,b,c;
void euclid(int a,int b,int *d,int *x,int *y){
if(!b){
*d = a,*x = 1,*y = 0;
}else{
int x0,y0;
euclid(b,a%b,d,&x0,&y0);
*x=y0;
*y=x0-(a/b)*y0;
}
}
int main()
{
fin>>T;
while(T--){
fin>>a>>b>>c;
int d,x,y;
euclid(a,b,&d,&x,&y);
if(c%d==0)
fout<<x*(c/d)<<" "<<y*(c/d)<<'\n';
else
fout<<"0 0\n";
}
return 0;
}