Pagini recente » Cod sursa (job #3122994) | Cod sursa (job #966536) | Cod sursa (job #857085) | Cod sursa (job #862942) | Cod sursa (job #3125370)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int euclid(int a, int b, int &d, int &x, int &y){
if(b == 0){
d = a;
x = y = 1;
}
else{
int x1,y1;
euclid(b, a % b, d, x1, y1);
x = y1;
y = x1 - a / b * y1;
}
}
int main()
{
int n,i,a,b,c,d,x,y;
fin >> n;
for(i = 1; i <= n; i++){
fin >> a >> b >> c;
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;
}