Pagini recente » Cod sursa (job #3288939) | Cod sursa (job #2974472) | Cod sursa (job #3288921) | Cod sursa (job #2955952) | Cod sursa (job #2237774)
#include <fstream>
using namespace std;
uint32_t gcdExtended(uint32_t a, uint32_t b, uint32_t & x, uint32_t & y) {
if (a == 0) {
x = 0;
y = 1;
return b;
}
uint32_t x1, y1;
uint32_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");
uint32_t t;
fin>>t;
while(t--) {
uint32_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;
}