Pagini recente » Cod sursa (job #2425592) | Cod sursa (job #363438) | Cod sursa (job #1213943) | Cod sursa (job #202530) | Cod sursa (job #2507321)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int t, a, b, c, d, x, y, x0, y0;
void Solve(int a, int b){
if (!b){
d = a;
x = 1;
y = 0;
}
else{
Solve(b, a % b);
x0 = x;
y0 = y;
x = y0;
y = x0 - (a / b) * y0;
}
}
int main(){
fin >> t;
while (t--){
fin >> a >> b >> c;
Solve(a, b);
if (c % d)
x = y = 0;
fout << x * (c / d) << ' ' << y * (c / d) << '\n';
}
return 0;
}