Pagini recente » Cod sursa (job #2448827) | Cod sursa (job #2225285) | Cod sursa (job #63712) | Cod sursa (job #2964832) | Cod sursa (job #2566524)
#include <bits/stdc++.h>
using namespace std;
ifstream in;
ofstream out;
void euclid(int a, int b,int&d, int& x, int& y)
{
if (b == 0)
{
x = 1;
y = 0;
d = a;
}
else
{
int x0, y0;
euclid(b, a % b,d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int n, p;
int main() {
in.open("euclid3.in");
out.open("euclid3.out");
in >> n;
for (int i = 1; i <= n; i++)
{
int d, x, y, c,a,b;
in >> a >> b >> c;
euclid(a, b, d, x, y);
if (c % d)
out << 0 << " " << 0 << "\n";
else
out << (x * (c / d)) << " " << (y * (c / d)) << "\n";
}
return 0;
}