Pagini recente » Cod sursa (job #712304) | Cod sursa (job #162711) | Cod sursa (job #2770713) | Cod sursa (job #1507192) | Cod sursa (job #2257300)
#include <bits/stdc++.h>
using namespace std;
void euclid(int a, int b, int& x, int& y) {
if (b == 0) {
x = 1;
y = 0;
return ;
}
int x0 = x;
int y0 = y;
euclid(b, a % b, x0, y0);
int q = a / b;
x = y0;
y = x0 - q * x;
}
int main(){
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
int t;
scanf("%d", &t);
while (t--) {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
int x, y;
euclid(a, b, x, y);
long long aux = 1LL * a * x + 1LL * b * y;
if (c % aux != 0)
printf("0 0\n");
else
printf("%lld %lld\n", 1LL * x * c / aux, 1LL * y * c / aux);
}
return 0;
}