Pagini recente » Cod sursa (job #897325) | Cod sursa (job #1337191) | Cod sursa (job #466851) | Cod sursa (job #3293797) | Cod sursa (job #1452974)
#include<fstream>
using namespace std;
ofstream fout("euclid3.out");
ifstream fin("euclid3.in");
int t;
long int a, b, c, d, x, y;
void euclid(long int a, long int b, long int &x, long int &y)
{
if(!b) {
d = a;
x = 1;
y = 0;
}
else {
long int x0, y0;
euclid(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
fin >> t;
for(int i=1; i<=t; i++) {
fin >> a >> b >> c;
euclid(a, b, x, y);
if(c % d) fout << 0 << ' ' << 0 << '\n';
else fout << x * (int)(c / d) << ' ' << y * (int)(c / d) << '\n';
}
fin.close();
fout.close();
return 0;
}