Pagini recente » Cod sursa (job #3216793) | Cod sursa (job #425603) | Cod sursa (job #2926734) | Cod sursa (job #599767) | Cod sursa (job #1115810)
//#include "stdafx.h"
//references
//http://www.infoarena.ro/algoritmul-lui-euclid
#include <fstream>
#include <iostream>
std::ifstream in("euclid3.in");
std::ofstream out("euclid3.out");
void euclid(long a, long b, long c, long* x, long *y)
{
if (b==0)
{
*x = 1;
*y = 0;
}
else
{
long x0, y0;
euclid(b, a % b, c, &x0, &y0);
*x = y0;
*y = x0 = (a/b) * y0;
}
}
int main()
{
int T;
in >> T;
for (int i = 0; i < T; i++)
{
long a,b,c;
in >> a >> b >> c;
long* x, *y;
euclid(a,b,c, x, y);
out << x << " " << y;
}
}