Pagini recente » Cod sursa (job #2376108) | Cod sursa (job #2274721) | Cod sursa (job #2196829) | Cod sursa (job #2391359) | Cod sursa (job #2415675)
#include <bits/stdc++.h>
using namespace std;
void extins(int a, int b, int &d, int &x, int &y){
if(b == 0){
d = a;
x = 1;
y = 0;
}
else{
int x0 = 0, y0 = 0;
extins(b, a % b, d, x0, y0);
x = y0;
y = x0 - y0 * (a / b);
}
}
int main()
{
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int n;
fin >> n;
while(n){
int a, b, c;
fin >> a >> b >> c;
int x = 0, y = 0, d = 0;
extins(a, b, d, x, y);
if(c % d == 0) fout << x * (c / d) << " " << y * (c / d) << "\n";
else fout << "0 0\n";
n--;
}
return 0;
}