Pagini recente » Cod sursa (job #489282) | Cod sursa (job #2116257) | Cod sursa (job #1480790) | Cod sursa (job #2413507) | Cod sursa (job #2565185)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#define ll long long
using namespace std;
void euclid_extins(int a, int b, int &d, int &x, int &y) {
if(b == 0) {
x = 1;
y = 0;
d = a;
} else {
int x0, y0;
euclid_extins(b, (a % b), d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main() {
ifstream in("euclid3.in");
ofstream out("euclid3.out");
int ntests;
in >> ntests;
while(ntests --) {
int a, b, c;
in >> a >> b >> c;
int x, y, d;
euclid_extins(a, b, d, x, y);
if(c % d)
out << 0 << " " << 0 << "\n";
else
out << (x * (c / d)) << " " << (y * (c / d)) << "\n";
}
return 0;
}