Pagini recente » Cod sursa (job #1874298) | Cod sursa (job #1533444) | Cod sursa (job #51814) | Cod sursa (job #485554) | Cod sursa (job #1783763)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("euclid3.in");
ofstream t ("euclid3.out");
inline int euclidext( int a, int b, int &x, int &y )
{
if (b == 0)
{
x = 1;
y = 0;
return a;
}
int x0, y0, d;
d = euclidext( b, a % b, x0, y0 );
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main()
{ int a,b,c,n,x,y,z;
f>>n;
for (int i=0;i<n;++i){
f>>a>>b>>c;
z=euclidext(a,b,x,y);
if (c % z)
t<<"0 0"<<'\n';
else
t<<x * (c / z)<<" "<<y * (c / z)<<'\n';}
return 0;
}