code
#include <cstdio>
const int INF=0x3f3f3f;
const int maxn=1000005;
int remainder[maxn],integer[maxn];
int c[maxn],cc[maxn];
int main(){
//input
int n,d;
scanf("%d%d",&n,&d);
//do
if(n%d==0){
printf("%d.0\n",n/d);
}else{
int t=n/d;
printf("%d.",t);
int count=0;
while(t){
t/=10;
count++;
}
if(n/d==0) count++;
int x=2;
remainder[1]=n%d;
int l=-INF,r=-INF;
for(;x<=INF;x++){
integer[x]=remainder[x-1]*10/d;
remainder[x]=remainder[x-1]*10%d;
if(!remainder[x]) break;
if(c[remainder[x]]){
if(cc[c[remainder[x]]]==integer[x]){
l=c[remainder[x]];
r=x-1;
break;
}
}
c[remainder[x]]=x;
cc[c[remainder[x]]]=integer[x];
}
//output
int s=count+1;
for(int i=2;i<x;i++){
if(i==l){
printf("(");
s++;
}
if(s==76){
puts("");
s=0;
}
printf("%d",integer[i]);
s++;
if(s==76){
puts("");
s=0;
}
if(i==r){
printf(")");
s++;
}
if(s==76){
puts("");
s=0;
}
}
}
return 0;
}
78pts
dalao求调