Pagini recente » Cod sursa (job #254942) | Cod sursa (job #2646504) | Cod sursa (job #1519861) | Cod sursa (job #664732) | Cod sursa (job #1201667)
using namespace std;
#include <fstream>
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int c, x, y;
void euler(int, int) ;
int main()
{
int t, a, b;
fin >> t;
for(; t; --t)
{
fin >> a >> b >> c;
euler(a, b);
fout << x << ' ' << y << '\n';
}
return 0;
}
void euler(int a, int b)
{
if(!b)
{
if(c % a) x = y = 0;
else x = c / a, y = 0;
}
else
{
euler(b, a % b);
int aux = x;
x = y;
y = aux - a / b * y;
}
}