Pagini recente » Cod sursa (job #1906495) | Cod sursa (job #3037138) | Cod sursa (job #1401164) | Cod sursa (job #1279907) | Cod sursa (job #2975636)
#include<bits/stdc++.h>
using namespace std;
const int N = 0;
//ifstream in ("euclid3.in");
//ofstream out("euclid3.out");
auto& in = cin;
auto& out = cout;
int euclid(int a, int b, int &x, int &y)
{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
int xt, yt, d;
d = euclid(b, a%b, xt, yt);
x = yt;
y = xt - a / b * yt;
return d;
}
int main(){
int n, a, b, c, d, x, y;
for(in>>n; n>0; n--)
{
in>>a>>b>>c;
d = euclid(a, b, x, y);
if(c % d) out<<"0 0\n";
else out<<(c / d * x)<<' '<<(c / d * y)<<endl;
}
return 0;
}