Pagini recente » Cod sursa (job #1533449) | Cod sursa (job #1591126) | Cod sursa (job #1519053) | Cod sursa (job #2564002) | Cod sursa (job #616581)
Cod sursa(job #616581)
/*
* euclid3.cpp
*
* Created on: Oct 11, 2011
* Author: ruxy
*/
#include<fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
long long x0, y0,x,y,d;
void calcul(long long a,long long b) {
if (b == 0) {
d = a;
x0 = 1;
y0 = 0;
} else {
calcul( b, a % b);
x = y0;
y = x0 - (a / b) * y0;
x0=x;
y0=y;
}
}
int main() {
int T,i;
long long a,b,c;
f>>T;
for(i=1;i<=T;i++)
{
f >> a;
f >> b;
f >> c;
calcul( a, b);
float div = (float)c / d;
if ((c / d) == div)
{x = x * (c / d);
y = y * (c / d);
g << x << ' ' << y<<' ';
}
else g<<"0 0";
g<<'\n';
}
return 0;
}