Pagini recente » Cod sursa (job #3125322) | Cod sursa (job #2753830) | Cod sursa (job #1104275) | Cod sursa (job #2630242) | Cod sursa (job #2131599)
#include <iostream>
#include <fstream>
#include <vector>
#include <bits/stdc++.h>
#include <algorithm>
std::ifstream in("euclid3.in");
std::ofstream out("euclid3.out");
void euclid(int a, int b, int *d, int *x, int *y)
{
if (b == 0) {
*d = a;
*x = 1;
*y = 0;
} else {
int x0, y0;
euclid(b, a % b, d, &x0, &y0);
*x = y0;
*y = x0 - (a / b) * y0;
}
}
int main()
{
int t;
in >> t;
int a,b,c,d,x,y;
for(int i = 0 ; i < t ; i++)
{
in >> a >> b >> c;
euclid(a,b,&d,&x,&y);
if(c%d!=0)
out<<" 0 0\n";
else
{
x = x*(c/d);
y= y*(c/d);
out<< x <<" "<< y<<'\n';
}
}
return 0;
}