Pagini recente » Cod sursa (job #440476) | Cod sursa (job #629796) | Cod sursa (job #1889911) | Cod sursa (job #2722236) | Cod sursa (job #1066119)
#include <fstream>
using namespace std;
class eq{
public:
long long a, b, res;
eq(){};
eq(long long a1, long long b1, long long res1){
a = a1;
b = b1;
res = res1;
}
eq operator %(eq other){
long long t = res / other.res;
eq ans(a - t * other.a, b - t* other.b, res % other.res);
return ans;
}
};
eq gcd(eq x, eq y){
eq z;
while(y.res){
z = x;
x = y;
y = z % y;
}
return x;
}
int main(){
ifstream in("euclid3.in");
ofstream out("euclid3.out");
long long t;
in >> t;
while(t--){
long long x, y, z;
in >> x >> y >> z;
eq a(x, 0, x), b(0, y, y);
eq ans = gcd(a, b);
if(ans.res == 0){
out << "0 0\n";
continue;
}
if(z % ans.res != 0){
out << "0 0 \n";
continue;
}
out << ans.a / x * z / ans.res << " " << ans.b / y * z / ans.res << "\n";
}
return 0;
}