Pagini recente » Cod sursa (job #1645426) | Cod sursa (job #2715362) | Cod sursa (job #1391732) | Cod sursa (job #2455522) | Cod sursa (job #2668235)
#include <bits/stdc++.h>
int main() {
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
int t;
scanf("%d", &t);
int mat[2][3], c;
while (t--) {
scanf("%d %d %d", &mat[0][0], &mat[1][0], &c);
mat[0][1] = mat[1][2] = 1;
mat[0][2] = mat[1][1] = 0;
while (mat[0][0] && mat[1][0]) {
int r = mat[0][0] > mat[1][0] ? 0 : 1;
int c = mat[r][0] / mat[1 - r][0];
for (int j = 0; j < 3; j++)
mat[r][j] -= c * mat[1 - r][j];
}
int r = mat[0][0] ? 0 : 1;
if (c % mat[r][0] != 0) {
printf("0 0\n");
continue;
}
printf("%d %d\n", mat[r][1] * c / mat[r][0], mat[r][2] * c / mat[r][0]);
}
return 0;
}