Pagini recente » Cod sursa (job #2253779) | Cod sursa (job #755537) | Cod sursa (job #3180184) | Cod sursa (job #803779) | Cod sursa (job #3156969)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int gcd(int a, int b, int &x, int &y){
if(!b){
x = 1;
y = 0;
return a;
}
int x0,y0;
int d = gcd(b,a % b,x0,y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main()
{
int n,i,a,b,x,y,c,e = 0;
fin >> n;
for(i = 1; i <= n; i++){
fin >> a >> b >> c;
e = 0;
if(b > a){
swap(a,b);
e = 1;
}
int d = gcd(a,b,x,y);
if(c % d){
fout << "0 0\n";
continue;
}
if(!e) fout << (c / d) * x << " " << (c / d) * y << "\n";
else fout << (c / d) * y << " " << (c / d) * x << "\n";
//fout << (c / d) * x << " " << (c / d) * y << "\n";
}
return 0;
}