Pagini recente » Cod sursa (job #1044135) | Cod sursa (job #504217) | Cod sursa (job #737055) | Cod sursa (job #1501062) | 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;
}
}