Pagini recente » Cod sursa (job #3237779) | Cod sursa (job #3265215) | Cod sursa (job #2177252) | Cod sursa (job #1832761) | Cod sursa (job #3270580)
#include <iostream>
#include <fstream>
using namespace std;
void EuclidExtins(int a, int b, int &d, int &x, int &y)
{
if(b == 0)
{
x = 1;
y = 0;
d = a;
}
else
{
int x0, y0;
EuclidExtins(b, a%b, d, x0, y0);
x = y0;
y = x0-(a/b)*y0;
}
}
int inversMOD(int a, int n)
{
int d, x, y;
EuclidExtins(a, n, d, x, y);
while(x < 0)
x += n;
return x;
}
int main()
{
int t, a, b, c, d, x, y;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
fin >> t;
while(t--)
{
fin >> a >> b >> c;
EuclidExtins(a, b, d, x, y);
if(c%d != 0)
fout << "0 0\n";
else
{
int k = c/d;
x *= k;
y *= k;
fout << x << " " << y << "\n";
}
}
return 0;
}