Pagini recente » Cod sursa (job #2042910) | Cod sursa (job #1113553) | Cod sursa (job #1809525) | Cod sursa (job #1124710) | Cod sursa (job #2133494)
#include <fstream>
using namespace std;
ifstream fin;
ofstream fout;
int gcd_ext(int a, int b, int &x, int &y)
{
if (b==0)
{
x=1;
y=0;
return a;
}
int x1, y1;
int gcd=gcd_ext(b, a%b, x1, y1);
x=y1;
y=x1-(a/b)*y1;
return gcd;
}
int main()
{
fin.open("euclid3.in");
fout.open("euclid3.out");
int n;
fin >> n;
while(n)
{
--n;
int a, b, c;
fin >> a >> b >> c;
int x, y, d=gcd_ext(a, b, x, y);
if (c%d==0)
fout << x*c/d << " " << y*c/d << "\n";
else
fout << "0 0\n";
}
return 0;
}