Pagini recente » Cod sursa (job #1134588) | Monitorul de evaluare | Cod sursa (job #547585) | Cod sursa (job #2861451) | Cod sursa (job #2485082)
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
long long int d;
long long int x, y;
void euclide(long long int a, long long int b) {
//cout<<"1";
if (b == 0) {
d = a;
x = 1;
y = 0;
} else {
euclide(b, a % b);
long long int tmp = y;
y = x - (a/b)*y;
x = tmp;
}
}
int main() {
ios_base::sync_with_stdio(0);
long long int t;
in>>t;
while(t--) {
//cout<<"!";
long long int a, b, c;
in>>a>>b>>c;
euclide(a, b);
if(c % d){
out<<"0 0\n";
continue;
}
long long int tmp1 = c/d;
out<<x*tmp1<<' '<<y*tmp1<<'\n';
}
return 0;
}