Pagini recente » Cod sursa (job #2533733) | Cod sursa (job #1236741) | Cod sursa (job #2486705) | Arhiva de probleme | Cod sursa (job #1571085)
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int n, t, a, b, c, d, x, y, aux;
int cmmdc(int a, int b, int &x, int &y){
if(b==0){x=1; y=0; return a;}
int x0=0, y0=0, d=0;
d=cmmdc(b, a%b, x0, y0);
x=y0;
y=x0-(a/b)*y0;
return d;
}
int main(){
f>>t;
for(int test=1; test<=t; test++)
{
f>>a>>b>>c;
d=cmmdc(a, b, x, y);
aux=c/d;
x*=aux;
y*=aux;
if(c%d)
g<<"0 0\n";
else
g<<x<<' '<<y<<"\n";
}
return 0;
}