Pagini recente » Cod sursa (job #888641) | Cod sursa (job #1244436) | Cod sursa (job #1602348) | Cod sursa (job #2630470) | Cod sursa (job #1943437)
#include <iostream>
#include <fstream>
#include <limits.h>
using namespace std;
int euclid(int a, int b, int &x, int &y)
{
if (b == 0){
x = 1;
y = 0;
return a;
}
else{
int x0,y0,c;
c = euclid(b,a%b,x0,y0);
x = y0;
y = x0 - (a/b)*y0;
return c;
}
}
int main()
{
ifstream in("euclid3.in");
ofstream out("euclid3.out");
int t;
int a,b,c,aux;
int x,y;
f>>t;
for(int i=0;i<t;++i){
in>>a>>b>>c;
aux = euclid(a,b,x,y);
if (c % aux)
out << "0 0"<<'\n';
else
out << x << y << '\n';
}
return 0;
}