Pagini recente » Cod sursa (job #1339929) | 6pb | Cod sursa (job #1815920) | Cod sursa (job #2186284) | Cod sursa (job #1699176)
#include <iostream>
#include <fstream>
using namespace std;
long long cmmdcEuclid(long long a, long long b);
inline int gcdEuclid(int a, int b, int &x, int &y) {
if ( b == 0 ) {
x = 1;
y = 0;
return a;
}
int x0, y0;
int d = gcdEuclid(b, a % b, x0, y0);
y = x0 - (a / b) * y0;
x = y0;
return d;
}
int main() {
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int t;
f>>t;
int a,b,c;
for (int i = 0; i < t; ++i) {
f>>a;
f>>b;
f>>c;
int x, y;
int d = gcdEuclid(a, b, x, y);
if ( c % d ) {
g<<0<<" "<<0<<"\n";
} else {
g<<x * ( c / d)<<" "<<y * ( c / d)<<"\n";
}
}
f.close();
g.close();
}