![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
1 var
2 s:ansistring;
3 bz:array[0..99999] of longint;
4 i,j,k,m,n,last,wei:longint;
5 procedure print;
6 var
7 i:longint;
8 begin
9 for i:=1 to length(s) do
10 begin
11 write(s[i]);
12 if i mod 76=0 then writeln;
13 end;
14 if i mod 76<>0 then writeln;
15 end;
16 begin
17 assign(input,'fracdec.in');reset(input);
18 assign(output,'fracdec.out');rewrite(output);
19 readln(m,n);
20 fillchar(bz,sizeof(bz),0);
21 str(m div n,s);
22 k:=length(s);
23 s:=s+'.';
24 wei:=1;
25 last:=m mod n;
26 bz[last]:=1;
27 if m mod n=0 then
28 begin
29 s:=s+'0';
30 print;
31 end else
32 begin
33 repeat
34 inc(wei);
35 last:=last*10;
36 s:=s+chr(last div n+48);
37 last:=last mod n;
38 if bz[last]<>0 then break else bz[last]:=wei;
39 until (last=0);
40 if last=0 then print else
41 begin
42 insert('(',s,k+bz[last]+1);
43 s:=s+')';
44 print;
45 end;
46 end;
47 end.