Pagini recente » Cod sursa (job #2435034) | Cod sursa (job #650062) | Cod sursa (job #1375155) | Cod sursa (job #2693685) | Cod sursa (job #2450958)
//ALEXANDRU MICLEA
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <time.h>
#include <iomanip>
#include <deque>
#include <math.h>
#include <cmath>
#include <assert.h>
#include <stack>
#include <bitset>
#include <random>
#include <chrono>
using namespace std;
#include <fstream>
ifstream cin("euclid3.in"); ofstream cout("euclid3.out");
void euclid_ext(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;
euclid_ext(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main() {
long long n;
cin >> n;
for (int i = 1; i <= n; i++) {
long long a, b, c, x, y, d;
cin >> a >> b >> c;
euclid_ext(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;
}