Pagini recente » Cod sursa (job #597163) | Cod sursa (job #368382) | Cod sursa (job #1440605) | Cod sursa (job #2219065) | Cod sursa (job #2900036)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int n, a, b, c;
int gcd(int a, int b, int &x, int &y){
if(b == 0){
x = 1;
y = 0;
return a;
}
else{
int x1 , y1;
int g = gcd(b, a % b, x1, y1);
x = y1;
y = x1 - y1 * (a / b);
return g;
}
}
int main(){
fin >> n;
while(n){
n --;
fin >> a >> b >> c;
int x, y;
int g = gcd(a, b, x, y);
if(c % g) fout << 0 << " " << 0 << '\n';
else fout << x * (c/g) << " " << y * (c/g) << '\n';
}
}