Pagini recente » Cod sursa (job #1422206) | Cod sursa (job #1278622) | Cod sursa (job #2522697) | Cod sursa (job #2450850) | Cod sursa (job #1617415)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void euclid( long long a, long long b, long long *c, long long *x, long long *y)
{
if ( b== 0)
{
*c = a;
*x = 1;
*y = 0;
}
else
{
long long x0, y0;
euclid(b, a%b, c, &x0, &y0);
*x = y0;
*y = x0 - (a/b)*y0;
}
}
int main()
{
int t;
long long a, b, c;
long long x, y;
fin >> t;
for (int i = 1; i <= t; i++ )
{
fin >> a >> b >> c;
euclid(a, b, &c, &x, &y);
if( x == 1 && y== 0)
fout<<"0 0\n";
else fout << x <<" "<< y << "\n";
}
return 0;
}