cheeeeeeee

program Neayo;
const
        inf='light.in';
        ouf='light.out';
var
        i,j,k,m,n:longint;
        exp,sr,sl,l,r:extended;
        x,y,tan:array[0..100001]of extended;
procedure qsort(r,l:longint);
var tmp,xx:extended;
    i,j:longint;
begin
     i:=l;j:=r;
     xx:=x[l+random(r-l+1)];
     repeat
           while x[i]<xx do inc(i);
           while x[j]>xx do dec(j);
           if i<=j then
           begin
                tmp:=x[i];x[i]:=x[j];x[j]:=tmp;
                tmp:=y[i];y[i]:=y[j];y[j]:=tmp;
                tmp:=tan[i];tan[i]:=tan[j];tan[j]:=tmp;
                inc(i);
                dec(j);
           end;
     until(i>j);
     if i<r then qsort(i,r);
     if l<j then qsort(l,j);
end;
procedure init;
var tmp,z:extended;
begin
     assign(input,inf);assign(output,ouf);
     reset(input);rewrite(output);
     readln(n,sl,sr);
     tmp:=pi/180;
     for i:=1 to n do
     begin
          readln(x[i],y[i],z);
          tan[i]:=sin(z*tmp)/cos(z*tmp);
     end;
     qsort(1,n);
     close(input);
end;
function judge(h:extended):boolean;
var now,tmp:extended;
begin
     now:=sl;
     for i:=1 to n do
     begin
          tmp:=(y[i]-h)*tan[i];
          if now>x[i]-tmp then
          begin
               if x[i]+tmp>now then now:=tmp+x[i];
          end;
     end;
     if now>sr then exit(true)
     else exit(false);
end;
procedure go;
begin
     l:=0;
     r:=1000;
     exp:=1e-8;
     while r-l>exp do
     begin
          if judge((r+l)/2) then  l:=(r+l)/2
          else r:=(r+l)/2;
     end;
     writeln(l:0:7);
end;
begin
     init;
     go;
     close(output);
end.
posted @ 2012-10-15 19:58  neayo  阅读(193)  评论(0编辑  收藏  举报