Pagini recente » Cod sursa (job #3271336) | Cod sursa (job #3123080) | Cod sursa (job #2281058) | Cod sursa (job #2211741) | Cod sursa (job #3130439)
#include<bits/stdc++.h>
using namespace std;
ifstream fin("date.in");
ofstream fout("date.out");
int euclid(int a, int b, int &x, int &y)
{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
else
{
int x1, y1;
int sol = euclid(b, a%b, x1, y1);
x = y1;
y = x1 - (a/b) * y1;
return sol;
}
}
int main()
{
int n,a,b,c;
fin >> n;
while(n--)
{
fin >> a >> b >> c;
int x, y;
int d = euclid(a, b, x, y);
if(c%d == 0)
{
fout << (c / d) * x << " " << (c / d) * y << "\n";
}
else
{
fout << "0 0\n";
}
}
return 0;
}