/*
ID: niepeng1
LANG: C++
TASK:fracdec
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <ctype.h>
//#include <iostream.h>
#define Max1 1001000
char s[Max1]={" "};
int c[Max1]={0};
bool cond[Max1]={false};
int main()
{
int a,b,tem,tem1,j,i=0,point=0,k=0,a1;
bool cond1=false;
FILE *in,*out;
in=fopen("fracdec.in","r");
out=fopen("fracdec.out","w");
fscanf(in,"%d %d",&a1,&b);
{
a=a1;
tem=a/b;
a = a-tem*b;
fprintf(out,"%d",tem);
if(tem==0)
k=1;
else while(tem>0){tem/=10;k++;}
}
// s[i++]='.';
fprintf(out,".");k++;
if( a == 0){
fprintf(out,"0/n");
return 0;
}
a = a*10;
for(;;){
cond[a]=true;
tem = a/b;
tem1=a-tem*b;
c[i] =a;
s[i]=tem+'0';
i++;
if( tem1 == 0 ){
for(j=0;j<i;j++,k++){
if( (k+1)%76==0)
{
fprintf(out,"/n");
}
fprintf(out,"%c",s[j]);
}
fprintf(out,"/n");
return 0;
}
else{
if( cond[tem1*10] == true){
point=tem1*10;
if(point == (a1- (a1/b)*b)*10)
{
fprintf(out,"(");
cond1=true;
}
for(j=0;j<i;j++,k++){
if(c[j]==point&&cond1==false)//j <i-1
{
fprintf(out,"(");
cond1=true;
}
if( (k+1)%76==0)
{
fprintf(out,"/n");
}
fprintf(out,"%c",s[j]);
}
fprintf(out,")/n");
return 0;
}
}
a=tem1*10;
}
fclose(in);
fclose(out);
return 0;
}
/*处于无限拍错中,就是把测试错误结果返回来才认真看代码,哎,太粗心了。他妈的眼都看晕了。*/