Pagini recente » Cod sursa (job #309514) | Cod sursa (job #3180922) | Cod sursa (job #1891957) | Cod sursa (job #2030701) | Cod sursa (job #1648188)
#include <fstream>
typedef long long ll;
using namespace std;
int t;
ll x, y, a, b, c, div;
ll eux(ll nr1, ll nr2, ll &x, ll &y){
ll x0, y0, d;
if(nr2){
d = eux(nr2, nr1%nr2, x, y);
x0 = x;
y0 = y;
x = y0;
y = x0 - (nr1/nr2)*y0;
return d;
}
else {
x = 1; y = 0;
return nr1;
}
}
int main()
{
ifstream in("euclid3.in");
ofstream out("euclid3.out");
in>>t;
while(t--){
in>>a>>b>>c;
div = eux(a, b, x, y);
if(c%div) {
out<<"0 0\n";
}
else {
out<<x * c/div<<" "<<y * c/div<<"\n";
}
}
in.close();
out.close();
return 0;
}