Pagini recente » Cod sursa (job #2251952) | Cod sursa (job #1404916) | Cod sursa (job #2678147) | Cod sursa (job #1130426) | Cod sursa (job #2367412)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <queue>
#define ll long long
#define ull unsigned long long
#define lsb(x) (x & -x)
using namespace std;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
int euclid(int a, int b, int &x, int &y) {
if(b == 0) {
y = 0;
x = 1;
return a;
}
int x0, y0;
int d = euclid(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main() {
int ntests;
in >> ntests;
while(ntests --) {
int a, b, c;
in >> a >> b >> c;
int x, y;
int d = euclid(a, b, x, y);
if(c % d)
out << 0 << " " << 0 << "\n";
else
out << x * (c / d) << " " << y * (c / d) << "\n";
}
return 0;
}