Pagini recente » Cod sursa (job #2653887) | Cod sursa (job #492657) | Cod sursa (job #3239782) | Cod sursa (job #869358) | Cod sursa (job #2660992)
#include <iostream>
#include <fstream>
using namespace std;
void Eu_Extins(int a, int b, int &cmmdc, int &x, int &y)
{
if(!b)
{
cmmdc = a;
x = 1;
y = 0;
}
else
{
int x1, y1;
Eu_Extins(b, a % b, cmmdc, x1, y1);
x = y1;
y = x1 - (a / b) * y1;
}
}
int main()
{
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int T, a, b, c;
f >> T;
for(int i = 1, cmmdc; i <= T; i++)
{
f >> a >> b >> c;
int x, y;
Eu_Extins(a, b, cmmdc, x, y);
if(c % cmmdc == 0)
g << x * (c / cmmdc) << ' ' << y * (c / cmmdc) << '\n';
else
g << "0 0\n";
}
return 0;
}