/* ACM North Central Region, 1994-95 Problem B, Rational Numbers from Repeating Fractions Ed Karrels, May 1996 */ #include <stdio.h> #include <math.h> int main() { double x, y; int k, j, i, a, b, c=1; scanf("%d %lf", &j, &x); while (j != -1) { y = x * pow(10, j); for (k=0; y != (double)((long)y); y*=10,k++); a = (int)(pow(10, k+j)*x) - (int)(pow(10,k)*x); b = pow(10, k+j) - pow(10,k); for (i=a<b ? a : b; a%i || b%i; i--); a/=i; b/=i; printf("Case %d: %d/%d\n", c++, a, b); scanf("%d %lf", &j, &x); } return 0; }