Pagini recente » Cod sursa (job #22853) | Cod sursa (job #1842674) | Cod sursa (job #2171282) | Cod sursa (job #1289632) | Cod sursa (job #2561731)
#include <fstream>
using namespace std;
ifstream fin ("euclid3.in");
ofstream fout ("euclid3.out");
int x, y;
int Euclid_extins ( int a, int b );
int main()
{
int t, a, b, c, d;
fin >> t;
while ( t-- )
{
fin >> a >> b >> c;
d = Euclid_extins ( a, b );
if ( c % d == 0 ) fout << x * ( c / d ) << ' ' << y * ( c / d ) << '\n';
else fout << 0 << ' ' << 0 << '\n';
}
return 0;
}
int Euclid_extins ( int a, int b )
{
int cx, d;
if ( b == 0 )
{
x = 1;
y = 0;
return a;
}
else
{
d = Euclid_extins ( b, a % b );
cx = x;
x = y;
y = cx - ( a / b ) * y;
return d;
}
}