Pagini recente » Cod sursa (job #1534978) | Cod sursa (job #2326451) | Cod sursa (job #928369) | Cod sursa (job #1527763) | Cod sursa (job #2070387)
#include <fstream>
#include <iostream>
#include <cstring>
#include <unordered_map>
#include <map>
#include <bitset>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int a, b, c, x, y, d, T;
void euclid(int a, int b)
{
if(b == 0)
{
x = 1;
y = 0;
d = a;
}
else
{
int x0, y0;
euclid(b, a % b);
x0 = x;
y0 = y;
x = y0;
y = x0 - (a/b) * y0;
}
}
int main()
{
f >> T;
while (T)
{
f >> a >> b >> c;
euclid(a, b);
cout << d << '\n';
if(c % d == 0) g << x * (c / d) << ' ' << y * (c / d) << '\n';
else g << "0 0\n";
T--;
}
return 0;
}