Pagini recente » Cod sursa (job #2988617) | Cod sursa (job #3250916) | Cod sursa (job #2916006) | Cod sursa (job #569257) | Cod sursa (job #2738323)
#include <iostream>
#include <fstream>
#define ll long long
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int t;
ll x, y;
ll gcdExtins(ll a, ll b)
{ if(!b)
{ x = 1;
y = 0;
return a;
}
int g = gcdExtins(b, a % b);
int x1 = y, y1 = x - a / b * y;
x = x1;
y = y1;
return g;
}
int main()
{
fin >> t;
while(t--)
{ ll a, b, c;
fin >> a >> b >> c;
ll g = gcdExtins(a, b);
cout << g << ' ' << x << ' ' << y << '\n';
if(c % g != 0)
{ fout << 0 << ' ' << 0 << '\n';
continue;
}
fout << x * (c / g) << ' ' << y * (c / g) << '\n';
}
return 0;
}