// UVa 10976 - Fractions Again?! #include <stdio.h> int main() { int k; while (scanf("%d\n", &k) != EOF) { int sol_count = 0, sol[k][2]; for (int y = k + 1; y <= 2 * k; y++) { if ((k * y) % (y - k) == 0) { sol[sol_count][0] = (k * y) / (y - k); sol[sol_count++][1] = y; } } printf("%d\n", sol_count); for (int i = 0; i < sol_count; i++) printf("1/%d = 1/%d + 1/%d\n", k, sol[i][0], sol[i][1]); } return 0; }
No comments:
Post a Comment