好题,这题可以分开算每个技能的贡献
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.
时间: 2024-10-04 23:55:44