Pagini recente » Cod sursa (job #1169305) | Cod sursa (job #2917000) | Cod sursa (job #2668723) | Cod sursa (job #2513977) | Cod sursa (job #3240308)
#include<bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int64_t t, A, B, C;
int64_t MODINVERSE(int64_t a, int64_t b, int64_t& x, int64_t& y){
if(!b){
x = 1;
y = 0;
return a;
}
else{
int64_t newX, newY;
int64_t d = MODINVERSE(b, a % b, newX, newY);
x = newY;
y = newX - (a / b) * newY;
return d;
}
}
int main(){
fin >> t;
for(;t--;){
fin >> A >> B >> C;
int64_t x, y;
int d = MODINVERSE(A, B, x, y);
if(C % d)
fout << "0 0\n";
else
fout << x * (C / d) << ' ' << y * (C / d) << '\n';
}
}