Pagini recente » Cod sursa (job #1895546) | Cod sursa (job #1025338) | Cod sursa (job #1142224) | Cod sursa (job #2110513) | Cod sursa (job #2237775)
#include <fstream>
using namespace std;
uint64_t gcdExtended(uint64_t a, uint64_t b, uint64_t & x, uint64_t & y) {
if (a == 0) {
x = 0;
y = 1;
return b;
}
uint64_t x1, y1;
uint64_t d = gcdExtended(b % a, a, x1, y1);
x = y1 - (b / a) * x1;
y = x1;
return d;
}
int main() {
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
uint64_t t;
fin>>t;
while(t--) {
uint64_t a,b,c,x,y,d;
fin>>a>>b>>c;
d=gcdExtended(a,b,x,y);
if(c%d)
fout<<0<<' '<<0<<'\n';
else
fout<<(x*c)%d<<' '<<(y*c)%d<<'\n';
}
return 0;
}