Pagini recente » Cod sursa (job #1107398) | Cod sursa (job #2414390) | Cod sursa (job #2856412) | Cod sursa (job #743565) | Cod sursa (job #2859002)
#include <fstream>
#define int long long
using namespace std;
int _gcd (int a, int b, int &x, int &y){
if (!b){
x = 1;
y = 0;
return a;
}
else{
int x0, y0, d;
d = _gcd(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
}
signed main(){
ifstream fin ("euclid3.in");
ofstream fout ("euclid3.out");
int n, d;
fin >> n;
for (int i = 1; i <= n; i++){
int a, b, c, d, x, y;
fin >> a >> b >> c;
d = _gcd(a, b, x, y);
if (c % d)
fout << "0 0 \n";
else
fout << (c / d) * x << " " << (c / d) * y << "\n";
}
return 0;
}