Pagini recente » Cod sursa (job #3139138) | Cod sursa (job #320536) | Cod sursa (job #313588) | Cod sursa (job #2889308) | Cod sursa (job #1537207)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int n;
void euclid(int a, int b, int* x, int* y,int* d) {
if(b == 0) {
*x = 1;
*y = 0;
*d = a;
} else {
int y0;
int x0;
euclid(b, a % b, &x0, &y0, d);
int c = a / b;
*x = y0;
*y = 1LL* x0 - c * y0;
}
}
int main() {
int a; int b; int c;
int x; int y; int d;
fin >> n;
while(n--) {
fin >> a >> b >> c;
euclid(a, b, &x, &y, &d);
if(c % d != 0)
fout << 0 << " " << 0 << '\n';
else
fout << x * c / d << " " << y * c / d << '\n';
}
return 0;
}