Pagini recente » Autentificare | Cod sursa (job #83477) | Cod sursa (job #2344656) | Cod sursa (job #3294567) | Cod sursa (job #3298935)
#include <iostream>
#include <fstream>
using namespace std;
int euclid_extins(int a,int b,int &x,int &y)
{
if (b == 0) {
x = 1;
y = 0;
return a;
}
int x1, y1;
int d = euclid_extins(b, a % b, x1, y1);
x = y1;
y = x1 - (a / b) * y1;
return d;
}
int main()
{
int a,b,c,T,x,y,d ;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
fin>>T;
for(int i=0;i<T;i++)
{
fin>>a>>b>>c;
d=euclid_extins(a,b,x,y);
if (c%d!=0) {
fout<<"0 0"<<endl;
}
else {
x=x*(c/d);
y=y*(c/d);
fout<<x<<" "<<y<<endl;
}
}
}