|
|
вернуться в форумWhy I get WA? Pelase, help me!!!!!!! (+) My program: Program t1159;{$N+} Const MaxN = 100; Change = 180/Pi; OkW = 360.0; Eps = 1E-15; Eps2 = 1E-3; Var Block : array[1..MaxN]of integer; N,i,sum,max : integer; mx,t : integer; left,rigth : extended; middle : extended; curW : extended; ok : boolean; Function GetLW(R : extended;L : integer) : extended; Var cosw,w,tgw : extended; begin cosw:=(2*R*R-L*L)/(2*R*R); if cosw=0 then w:=90 else begin tgw:=sqrt(1-cosw*cosw)/cosw; w:=ArcTan(tgw)*Change; if w<0 then w:=180+w; end; GetLW:=w; end; Function GetW(R : extended) : extended; Var w : extended; j : integer; begin w:=0; for j:=1 to N do w:=w+GetLW(R,Block[j]); GetW:=w; end; Function GetS(R : extended) : extended; Var Ans,p,S : extended; i : integer; begin Ans:=0; for i:=1 to N do begin p:=(2*R+Block[i])/2; S:=sqrt(abs(p*(p-R)*(p-R)*(p-Block[i]))); Ans:=Ans+S; end; GetS:=Ans; end; Procedure WriteAns(R : extended); begin Writeln(GetS(R):0:2); Halt(0); end; Procedure WriteAns2(R : extended); Var S,p : extended; begin p:=(2*R+Block[N+1])/2; S:=sqrt(p*(p-R)*(p-R)*(p-Block[N+1])); Writeln(GetS(R)-S:0:2); {Halt(0);} end; begin Read(N); sum:=0; max:=0; for i:=1 to N do begin Read(Block[i]); sum:=sum+Block[i]; if Block[i]>max then begin max:=Block[i]; mx:=i; end; end; if mx<>N then begin t:=Block[mx]; Block[mx]:=Block[N]; Block[N]:=t; end; if max>=sum-max then begin writeln('0.00'); halt(0); end; if max mod 2=0 then max:=max div 2 else max:=1+(max div 2); left:=max; rigth:=sum; While True do begin middle:=(left+rigth)/2; curW:=GetW(middle); if curW<OkW then rigth:=middle else left:=middle; if rigth-left<Eps then break; end; if abs(curW-OkW)<Eps2 then WriteAns(middle); N:=N-1; left:=max; rigth:=1E10; While True do begin middle:=(left+rigth)/2; curW:=GetW(middle); if curW>GetLW(middle,Block[N+1]) then rigth:=middle else left:=middle; if rigth-left<Eps then break; end; writeans2(middle); end. |
|
|