Pagini recente » Cod sursa (job #3277606) | Cod sursa (job #2695427) | Cod sursa (job #2743817) | Cod sursa (job #913743) | Cod sursa (job #2718142)
#include <fstream>
int x, y, d;
void euclid(int a, int b, int& x, int& y, int& d) {
if(b==0) {
x = 1, y = 0, d = a;
return;
}
euclid(b, a%b, x, y, d);
int nwx = y, nwy = x - y * (a/b);
x = nwx, y = nwy;
}
int main() {
std::ifstream fin("euclid3.in");
std::ofstream fout("euclid3.out");
int t, a, b, c;
fin>>t;
while(t--) {
fin>>a>>b>>c;
euclid(a, b, x, y, d);
if(c%d==0) fout<<x*(c/d)<<" "<<y*(c/d)<<"\n";
else fout<<"0 0\n";
}
}