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