Pagini recente » Cod sursa (job #2124490) | Cod sursa (job #814263) | Cod sursa (job #53683) | Cod sursa (job #1309080) | Cod sursa (job #1565187)
#include<fstream>
#include<algorithm>
#include<string.h>
using namespace std;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
void euclid_extins(int a, int b, int &x, int &y, int &r)
{
if (b)
{
int x0 = 0, y0 = 0;
euclid_extins(b, a%b, x0, y0, r);
x = y0;
y = x0 - y0*(a / b);
}
else
{
x = 1;
y = 0;
r = a;
}
}
int main()
{
int T,a,b,c,x,y,r;
in >> T;
for (int i = 1;i <= T;++i)
{
in >> a >> b >> c;
euclid_extins(a, b, x, y, r);
if (c%r == 0)
{
out << x*(c/r) << " " << y*(c/r)<<'\n';
}
else
out << "0 0";
}
return 0;
}