Pagini recente » Cod sursa (job #304268) | Cod sursa (job #1825892) | Cod sursa (job #1937082) | Cod sursa (job #1321917) | Cod sursa (job #3139958)
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
void EuclidExtins(int a, int b, int &d, int &x, int &y)
{
if(b == 0)
{
x = 1, y = 0, d = a;
}
else
{
int x0, y0;
EuclidExtins(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main() {
int n;
f >> n;
for(int i = 0; i < n; i++) {
int a, b, c, d, x, y;
f >> a >> b >> c;
EuclidExtins(a, b, d, x, y);
if(c % d)
g << "0 0\n";
else
g << (c / d) * x << ' ' << (c / d) * y << '\n';
}
return 0;
}