Pagini recente » Cod sursa (job #2904716) | Cod sursa (job #896422) | Cod sursa (job #1400117) | Rating Chindris Liviu Ion (chindrisliviuion) | Cod sursa (job #3146707)
#include <bits/stdc++.h>
#define mod 100003
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int t, a, b, c, x, y, d;
static inline void cmmdc(int a, int b, int & d, int & x, int & y) {
if(b == 0) {
d = a;
x = 1;
y = 0;
}
else {
int x1, y1;
cmmdc(b, a % b, d, x1, y1);
x = y1;
y = x1 - (a / b) * y1;
}
}
int main() {
fin >> t;
while(t--) {
fin >> a >> b >> c;
cmmdc(a, b, d, x, y);
if(c % d == 0) fout << x * (c / d) << " " << y * (c / d) << "\n";
else fout << "0 0\n";
}
return 0;
}