Pagini recente » Cod sursa (job #793364) | Cod sursa (job #792847)
Cod sursa(job #792847)
#include <cstdio>
using namespace std;
void euclid(int a, int b, int &x, int &y, int &d){
if (b == 0){
d = a;
x = 1;
y = 0;
return;
}
int x0;
int y0;
euclid (b, a % b, x0, y0, d);
x = y0;
y = x0 - y0 * (a / b);
}
void rez(){
int a;
int b;
int c;
scanf ("%d%d%d", &a, &b, &c);
int x;
int y;
int d;
euclid (a, b, x, y, d);
if (c % d != 0){
printf ("0 0\n");
return;
}
x *= c / d;
y *= c / d;
printf ("%d %d\n", x, y);
}
int main()
{
freopen ("euclid3.in", "r", stdin);
freopen ("euclid3.out", "w", stdout);
int t;
scanf ("%d", &t);
while (t--){
rez();
}
return 0;
}