Pagini recente » Cod sursa (job #1346202) | Cod sursa (job #2187729) | Cod sursa (job #626976) | Cod sursa (job #1284359) | Cod sursa (job #3357402)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void euclid(int a, int b, long long &d, long long &x, long long &y)
{
if (b == 0) {
d = a;
x = 1;
y = 0;
} else {
long long x0, y0;
euclid(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
int t,a,b,c;
fin>>t;
for(int i=1;i<=t;i++){
fin>>a>>b>>c;
long long d,x,y;
euclid(a,b,d,x,y);
if(c%d == 0){
fout<<x*c/d<< " "<<y*c/d<< '\n';
}
else{
fout<<0<< " "<<0<< '\n';
}
}
return 0;
}