Pagini recente » Cod sursa (job #1911727) | Cod sursa (job #2253225) | Cod sursa (job #748865) | Cod sursa (job #26354) | Cod sursa (job #3171191)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
void cmmdc (long long a, long long b, long long &d, long long &x, long long &y) {
if (b == 0) {
d = a;
x = 1;
y = 0;
}
else {
long long x0, y0;
cmmdc(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a/b) * y0;
}
}
int main() {
int t;
long long a, b, c;
f>>t;
for (int i = 1; i <= t; i++) {
f>>a>>b>>c;
long long d, x, y;
cmmdc(a, b, d, x, y);
if (c % d != 0) g<<0<<" "<<0<<endl;
else g<<x * (c/d)<<" "<<y * (c/d)<<endl;
}
return 0;
}