码迷,mamicode.com
首页 > 其他好文 > 详细

bzoj4008

时间:2015-05-18 10:38:36      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:

好题,这题可以分开算每个技能的贡献

orz popoqqq http://blog.csdn.net/popoqqq/article/details/45365759

技术分享
 1 var f,w:array[0..510,0..510] of double;
 2     p:array[0..510] of double;
 3     d:array[0..510] of longint;
 4     t,i,j,n,m:longint;
 5     ans:double;
 6 
 7 begin
 8   readln(t);
 9   while t>0 do
10   begin
11     dec(t);
12     readln(n,m);
13     fillchar(f,sizeof(f),0);
14     for i:=1 to n do
15       readln(p[i],d[i]);
16     ans:=0;
17     for i:=1 to n do
18     begin
19       w[i,0]:=1;
20       for j:=1 to m do
21         w[i,j]:=w[i,j-1]*(1-p[i]);
22     end;
23     f[0,m]:=1;
24     for i:=0 to n-1 do
25       for j:=0 to m do
26       begin
27         f[i+1,j]:=f[i+1,j]+f[i,j]*w[i+1,j];
28         if j>0 then
29         begin
30           f[i+1,j-1]:=f[i+1,j-1]+f[i,j]*(1-w[i+1,j]);
31           ans:=ans+f[i,j]*(1-w[i+1,j])*d[i+1];
32         end;
33       end;
34     writeln(ans:0:10);
35   end;
36 end.
View Code

 

bzoj4008

标签:

原文地址:http://www.cnblogs.com/phile/p/4511184.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!