Pagini recente » Cod sursa (job #2743343) | Profil CristinaPele | Cod sursa (job #129514) | Cod sursa (job #1179928) | Cod sursa (job #2037900)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("euclid3.in");
ofstream g ("euclid3.out");
int n,a,b,i,x,y,d,c;
int euclid(int a,int b,int &x,int &y)
{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
int x0,y0, c = euclid(b,a % b,x0,y0);
x = y0;
y = x0 - (a/b)*y0;
return c;
}
int main()
{
f >> n;
for(i = 1;i <= n;i++)
{
f >> a >> b >> d;
c = euclid(a,b,x,y);
if(d % c == 0)
g << x * (d / c) << " " << y * (d / c) << "\n";
else g << "0 0\n";
}
return 0;
}