Pagini recente » Istoria paginii runda/listare_probleme/clasament | Atasamentele paginii Clasament simulare_oji_1112 | Cod sursa (job #795756) | Monitorul de evaluare | Cod sursa (job #1682646)
#include <iostream>
#include <fstream>
using namespace std;
int f(int a, int b, int &x, int &y)
{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
int d = f(b, a%b, x, y);
b = x - (a/b)*y;
a = y;
x = a;
y = b;
return d;
}
int main()
{
int n, a, b, c, d, x, y;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
fin >> n;
for(int i = 1; i<=n; ++i)
{
fin >> a >> b >> c;
d = f(a,b,x,y);
if(c%d != 0)
fout << "0 0\n";
else
fout << x * (c/d) << ' ' << y * (c/d) << '\n';
}
return 0;
}