Pagini recente » Cod sursa (job #353238) | Cod sursa (job #1569115) | Autentificare | Cod sursa (job #188850) | Cod sursa (job #1984414)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
void euclid(int a, int b,int &d, int &x, int &y){
if(b==0){
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(){
int n;
in>>n;
for(int i=1;i<=n;i++){
int x = 0, y= 0,d=0;
int a, b , c;
in>>a>>b>>c;
euclid(a,b,d,x,y);
x =x* (c/d);
y =y* (c/d);
if(x*y!=0)out<<x<<' '<<y<<'\n';
else out<<'0'<<' '<<"0\n";
}
return 0;
}