Pagini recente » Diferente pentru problema/interclas intre reviziile 12 si 13 | Cod sursa (job #2269300) | Monitorul de evaluare | Cod sursa (job #1018986) | Cod sursa (job #3326185)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
void euclid(long long a, long long b, long long &d, long long &x, long long &y)
{
if(b == 0)
x = 1, y = 0, d = a;
else
{
long long x0, y0;
euclid(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
long long a, b, c, d, x, y;
int t;
f >> t;
for(int i = 1; i <= t; i++)
{
f >> a >> b >> c;
euclid(a, b, d, x, y);
if(c % d)
g << "0 0\n";
else
g << x*(c / d) << ' ' << y*(c / d) << '\n';
}
return 0;
}