这种题完全可以暴力找规律,暴力打表各种搞法

这里有一篇比较全面的题解:http://acm.uestc.edu.cn/bbs/read.php?tid=3698&page=1&toread=1#tpc

 1 var f:array[0..1510] of extended;
 2     n,m,i,j,t:longint;
 3 
 4 function pow(x,y:longint):extended;
 5   var i:longint;
 6   begin
 7     pow:=1;
 8     for i:=1 to y do 
 9       pow:=pow*x;
10   end;
11 
12 function C(n,m:longint):extended;
13   var i:longint;
14   begin
15     C:=1;
16     for i:=1 to m do
17     begin
18       C:=C*(i+m);
19       C:=C/i;
20     end;
21   end;
22 
23 begin
24   f[1]:=1;
25   for i:=2 to 1500 do
26   begin
27     j:=i-i and 1;
28     f[i]:=f[i-1]+C(j,j shr 1)/pow(2,j);
29   end;
30   readln(t);
31   for i:=1 to t do
32   begin
33     readln(n);
34     writeln('Case ',i,': ',f[n]:0:6);
35   end;
36 end.
View Code

 

posted on 2015-06-30 09:53  acphile  阅读(211)  评论(0编辑  收藏  举报