Pagini recente » Monitorul de evaluare | Rating Toma Brihacescu (TomaB) | Cod sursa (job #2010260) | Statistici andra ardna (andraardna) | Cod sursa (job #2485079)
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
ifstream in("euclid2.in");
ofstream out("euclid2.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;
}