Pagini recente » Cod sursa (job #849147) | Cod sursa (job #1385512) | Cod sursa (job #2751593) | Cod sursa (job #1026249) | Cod sursa (job #2048149)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int n;
void eucex(int a, int b, int& x, int& y, int& d)
{
if(!b)
{
d = a;
x = 1;
y = 0;
}
else
{
int xx, yy;
eucex(b, a%b, xx, yy, /*??*/d);
x = yy;
y = xx - (a / b) * yy;
}
}
int main()
{
ios::sync_with_stdio(false);
fin >> n;
while(n--)
{
int a, b, c;
fin >> a >> b >> c;
int x, y, d;
//cout << x << " " << y << " " << d << "\n";
eucex(a, b, x, y, d);
//cout << x << " " << y << " " << d << "\n";
if(c % d)
fout << "0 0\n";
else
fout << x * (c / d) << " " << y * (c / d) << "\n";
}
return 0;
}