Pagini recente » Cod sursa (job #2272417) | Cod sursa (job #2224720) | Cod sursa (job #2686244) | Cod sursa (job #2189279) | Cod sursa (job #2230272)
#include <iostream>
#include <fstream>
using namespace std;
typedef long long ll;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
void euclid_extins(ll &x,ll &y,ll a,ll b,ll &d){
if(b == 0){
d = a;
x = 1;
y = 0;
return;
}
euclid_extins(x,y,b,a % b,d);
ll newx = y;
ll newy = x - y*(a/b);
x = newx;
y = newy;
}
int main()
{
int n;
in>>n;
for(int i = 1; i <= n; i++){
ll a,b,c,d,x,y;
in>>a>>b>>c;
euclid_extins(x,y,a,b,d);
if(c % d != 0)
out<<0<<" "<<0;
else
out<<x * (c/d)<<" "<<y * (c/d);
out<<"\n";
}
return 0;
}