POJ 3122(二分答案)

来源:互联网 发布:数据机房装修要求 编辑:程序博客网 时间:2024/05/09 02:48

二分答案……


Program pie;const   lef=0.00001;var   t,n,f,i,j:longint;   r:array[1..10000] of longint;   s:array[1..10000] of double;   maxs:double;procedure sort(l,r:double);var   m:real;   i,j,tot:longint;begin   m:=(l+r)/2;   tot:=0;   for i:=1 to n do inc(tot,trunc(s[i]/m));   if tot>=f then   begin      if r-l<lef then writeln(r:4:4)      else sort(m,r);   end   else sort(l,m);end;begin   read(t);   while (t>0) do   begin      read(n,f);      inc(f);      for i:=1 to n do      begin         read(r[i]);         s[i]:=sqr(r[i])*pi;      end;      maxs:=s[1];      for i:=2 to n do         if maxs<s[i] then maxs:=s[i];      sort(0,maxs);      dec(t);   end;end.


原创粉丝点击