Pagini recente » Cod sursa (job #2686529) | Cod sursa (job #1997837) | Cod sursa (job #693017) | Cod sursa (job #2534815) | Cod sursa (job #2692285)
#include <stdio.h>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int INF = 0x3f3f3f3f;
ifstream fin ("euclid3.in");
ofstream fout ("euclid3.out");
int ext_gcd(int a, int b, int &x, int &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
int x1, y1;
int d = ext_gcd(b, a%b, x1, y1);
x = y1;
y = x1 - (a/b)*y1;
return d;
}
int main(void) {
// freopen("euclid3.in", "r", stdin);
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
int T, a, b, c, x, y, d;
fin >> T;
while(T--) {
fin >> a >> b >> c;
x = 0, y = 0;
d = ext_gcd(a, b, x, y);
if (c % d) {
fout << "0 0\n";
} else {
int k = c/d;
fout << k*x << " " << k*y << '\n';
}
}
return 0;
}