Pagini recente » Cod sursa (job #3260595) | Cod sursa (job #2771669) | Cod sursa (job #3262892) | Profil StarGold2 | Cod sursa (job #394870)
Cod sursa(job #394870)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int T;
void EuclidExtins(int a, int b, int &d, int &x, int &y)
{
if (b == 0)
{
d = a;
x = 1;
y = 0;
}
else
{
int x0, y0;
EuclidExtins(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
int i, k, a, b, c, x, y, d;
fin >>T;
for (k = 1; k <= T; k++)
{
fin >>a >>b >>c;
EuclidExtins(a, b, d, x, y);
if (c % d == 0)
{
fout <<x*(c/d) <<' '<<y*(c/d) <<'\n';
}
else
{
fout <<0 <<' ' <<0 <<'\n';
}
}
fin.close();
fout.close();
return 0;
}