Pagini recente » Cod sursa (job #2440807) | Cod sursa (job #508470) | Cod sursa (job #639367) | Cod sursa (job #408441) | Cod sursa (job #2754316)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const string file = "euclid3";
ifstream fin(file + ".in");
ofstream fout(file + ".out");
int q, a, b, c, d;
int euclid(int a, int b, int &x, int &y) {
if (!b) {
x = 1;
y = 0;
return a;
}
int x0, y0, d;
d = euclid(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main() {
int x, y;
fin >> q;
while (q--) {
fin >> a >> b >> c;
d = euclid(a, b, x, y);
if (c % d == 0)
fout << x * (c / d) << " " << y * (c / d) << "\n";
else fout << "0 0\n";
}
return 0;
}