Pagini recente » Cod sursa (job #1706078) | Cod sursa (job #1550724) | Cod sursa (job #1360736) | Cod sursa (job #415474) | Cod sursa (job #2450409)
//ALEX ENACHE
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <time.h>
#include <iomanip>
#include <deque>
#include <math.h>
#include <assert.h>
#include <stack>
#include <bitset>
#include <random>
using namespace std;
//-----------------------------------------------------------------
#include <fstream>
//ifstream cin("input"); ofstream cout("output");
ifstream cin("euclid3.in"); ofstream cout("euclid3.out");
void euclid(long long a, long long b, long long& d, long long& x, long long& y) {
if (b == 0) {
d = a; // am ajuns la gcd
x = 1; y = 0; // gcd * 1 + 0 = gcd (normal)
// << a << " " << b << " " << d << " " << x << " " << y << '\n';
}
else {
long long x0, y0; //acestea vor fi val pt b , a % b
euclid(b, a % b, d, x0, y0);
//x0 * b + y0 * (a%b) = d
//a%b = a - (a/b) * b
//x0 * b + y0 * (a - (a/b) * b) = d
//y0 * a + (x0 - y0 * (a/b)) * b = d
x = y0;
y = x0 - (a / b) * y0;
//cout << a << " " << b << " " << d << " " << x << " " << y << '\n';
}
}
int main() {
int t;
cin >> t;
while (t--) {
long long a, b, c , d , x , y;
cin >> a >> b >> c;
euclid(a, b, d, x, y);
if (c % d != 0) {
cout << 0 << " " << 0 << '\n';
continue;
}
long long m = c / d;
cout << m * x << " " << m * y << '\n';
}
return 0;
}