Pagini recente » Cod sursa (job #1099758) | Cod sursa (job #1820673) | Cod sursa (job #2504095) | Cod sursa (job #2625721) | Cod sursa (job #1904577)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int t, a, b, c, d, x, y;
int euclid(int a, int b, int &x, int &y)
{
if(b==0)
{
x=1;
y=0;
return a;
}
else
{
int x0, y0, d;
d=euclid(a, a%b, x0, y0);
x=y0;
y=x0-y0*(a/b);
return d;
}
}
void citire()
{
f>>t;
while(t--)
{
f>>a>>b>>c;
d=euclid(a, b, x, y);
if(c%d==0) g<<x*(c/d)<<" "<<y*(c/d)<<"\n";
else g<<"0 0\n";
}
}
int main()
{
citire();
return 0;
}