1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

long long int K,I,Lu,Ru,V,Ld,Rd,MyCase,D,U;
int J;
char MyString[12];
long long int MyGCD(long long int A,long long int B)
{
  long long int MyTemp;
  while(A%B)
   {
     MyTemp=A;
     A=B;
     B=MyTemp%B;
   }
   return B;
}
long long int MyLCM(long long int A ,long long int B)
{
    return (A*B)/(MyGCD(A,B));
}
long long int MyPow(long long int N)
{
    long long int MyTemp=1;
    while(N--)
    {
        MyTemp=MyTemp*10;
    }
    return MyTemp;
}
int main()
{
    while (EOF!=scanf("%d",&J))
    {
        if (J==-1)
            break;
        scanf("%s",MyString);
        I=strlen(MyString);
        Ru=atoi(MyString+1+J);
        MyString[1+J]='\0';
        Lu=atoi(MyString+2);
        Ld=MyPow(J-1);
        if (Lu==0)
        {
            Ld=1;
        }
        Rd=MyPow(I-2)-Ld;
        V=MyLCM(Ld,Rd);
        U=Lu*(V/Ld)+Ru*(V/Rd);
        D=MyGCD(V,U);
        printf("Case %lld: %lld/%lld\n",++MyCase,U/D,V/D);    /* %I64d for Windows */
    }
    return 0;
}