Pagini recente » Cod sursa (job #1604710) | Cod sursa (job #1785577) | Cod sursa (job #502322) | Cod sursa (job #675250) | Cod sursa (job #2677969)
#include <bits/stdc++.h>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int a,b,c;
int x, y;
int t;
int d;
void euclid_extins(int a, int b) {
if (b!=0) {
euclid_extins(b,a%b);
}
if (b==0) {
x=1;
y=0;
}
else {
int aux = x;
x = y;
y = aux - (a/b)*y;
}
}
int main()
{
f >> t;
for (int i=1;i<=t;i++) {
f >> a >> b >> c;
euclid_extins(a,b);
d = a*x + b*y;
double rez = 1.0*c/d;
if (rez==int(rez)) {
g << x*rez << " " << y*rez << '\n';
}
else {
g << 0 << " " << 0 << '\n';
}
}
return 0;
}