Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
想神牛求教!!!pascal伤不起啊.var f:array[0..51,0..60]of double; a:array[0..51]of longint; m,l,t,i:longint; ans:double; procedure init; var tmp,i:longint; ch:char; begin readln(m,l); fillchar(a,sizeof(a),0); a[m+2]:=-1; for i:=1 to m do begin read(ch); case ch of '-':begin read(tmp);a[i]:=-tmp; end; '+':begin read(tmp);a[i]:=tmp; end; 'L':a[i]:=-100000; '0':a[i]:=0; end; read(ch); end; readln; end; procedure dp; var i,j:longint; begin fillchar(f,sizeof(f),0); f[0,0]:=1.0; for i:=0 to l-1 do for j:=0 to m do begin if a[j+1]=-100000 then f[i+2,j+1]:=f[i+2,j+1]+f[i,j]*0.5 else f[i+1,j+1+a[j+1]]:=f[i+1,j+1+a[j+1]]+f[i,j]*0.5; if a[j+2]=-100000 then f[i+2,j+2]:=f[i+2,j+2]+f[i,j]*0.5 else f[i+1,j+2+a[j+2]]:=f[i+1,j+2+a[j+2]]+f[i,j]*0.5; end; end; begin readln(t); while t>0 do begin dec(t); init; dp; ans:=0; for i:=0 to l do ans:=ans+f[i,m+1]; if ans>0.5 then writeln('Bet for. ',ans:0:4) else if ans<0.5 then writeln('Bet against. ',ans:0:4) else writeln('Push. ',ans:0:4); end; end. ugly 见谅 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator