Pagini recente » Cod sursa (job #2430121) | Cod sursa (job #2232195) | Cod sursa (job #854344) | Cod sursa (job #2308020) | Cod sursa (job #2884184)
#include <bits/stdc++.h>
using namespace std;
void euclid(int a, int b, int &d, int &x, int &y) {
if(b==0) {
d = a;
x = 1;
y = 1;
}
else {
int x1;
int y1;
euclid(b, a%b, d, x1, y1);
x = y1;
y = x1 - 1LL * a / b * y1;
}
}
int main() {
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int t; f >> t;
while(t--) {
int a, b, c; f >> a >> b >> c;
int d, x, y;
euclid(a, b, d, x, y);
if(c % d == 0)
g << 1LL * c/d * x << " " << 1LL * c/d * y << "\n";
else g << "0 0\n";
}
return 0;
}