Pagini recente » Cod sursa (job #2582952) | Cod sursa (job #1754428) | Cod sursa (job #177317) | Cod sursa (job #2295675) | Cod sursa (job #651837)
Cod sursa(job #651837)
#include <fstream>
using namespace std;
ifstream in;
ofstream out;
inline void euclid_extins(int a,int b,int &d,int &x,int &y)
{
if(b==0)
{
d=a;
x=1;
y=0;
return;
}
int x0,y0;
euclid_extins(b,a%b,d,x0,y0);
x=y0;
y=x0-(a/b)*y0;
}
int main()
{
int Test,a,b,c,d,x,y;
in.open("euclid3.in");
out.open("euclid3.out");
in>>Test;
for(;Test--;)
{
in>>a>>b>>c;
euclid_extins(a,b,d,x,y);
if(c%d!=0) out<<"0 0\n";
else
{
c/=d;
out<<x*c<<' '<<y*c<<'\n';
}
}
in.close();
out.close();
return 0;
}