Pagini recente » Cod sursa (job #2837381) | Cod sursa (job #1559384) | Cod sursa (job #634613) | Cod sursa (job #1788685) | Cod sursa (job #2241894)
#include<iostream>
using namespace std;
#include <fstream>
ifstream fin ("euclid3.in");
ofstream fout ("euclid3.out");
int n, a, b, c, d, x, y;
int euclidext(int a, int b, int &x, int &y)
{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
int x1,y1;
d = euclidext(b, a%b , x1, y1);
x = y1;
y = x1 - (a/b)*y1;
return d;
}
int main ()
{
fin >> n;
for (int i = 0; i < n; ++i)
{
fin >> a >> b >> c;
d = euclidext(a, b, x, y);
if (c % d) fout << "0 0" << endl;
else fout << x*(c/d) <<' '<< y*(c/d) << endl;
}
return 0;
}