Pagini recente » Cod sursa (job #1246324) | Cod sursa (job #2040675) | Cod sursa (job #1876600) | Cod sursa (job #6121) | Cod sursa (job #2149998)
#include <iostream>
#include <fstream>
using namespace std;
int euclid(int a, int b, int &x, int &y)
{
if (b == 0) {
x = 1;
y = 0;
return a;
} else {
int x0, y0, rez;
rez = euclid(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return rez;
}
}
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int main()
{
int t, a, b, c;
f >> t;
for(int i = 1 ; i <= t; i++)
{
f >> a >> b >> c;
int x, y, rez;
rez = euclid(a, b, x, y);
if(c % rez)
g << "0 0" << '\n';
else
g << x *(c / rez)<< " " << y * (c / rez) << '\n';
}
}