Pagini recente » Cod sursa (job #1430451) | Cod sursa (job #830732) | Cod sursa (job #828156) | Cod sursa (job #714247) | Cod sursa (job #1232162)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int t, a, b, c, d;
void Euclid_Extins(int a, int b, int &d, int &x, int &y)
{
if(b == 0)
{
d = a;
x = 1;
y = 0;
}
else
{
int x0, y0;
Euclid_Extins(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
fin>>t;
while(t)
{
fin>>a>>b>>c;
t--;
int x, y;
Euclid_Extins(a,b,d,x,y);
if(c % d == 0)
cout<<x * (c / d)<<" "<<y * (c / d)<<"\n";
else
cout<<"0 0\n";
}
return 0;
}