ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1184. Cable Master

please see it? It got WA.
Послано zealot 19 ноя 2002 19:33
my solution:

{$N+}
program cable_master;
const max=10000;
var a:array[1..max] of real;
    n,k,s:integer;
    best,f,r,m:extended;
procedure readdata;
var i:integer;
begin
readln(n,k);
for i:=1 to n do
 begin
  readln(a[i]);
  if a[i]>r then r:=a[i];
 end;
end;
function find:boolean;
var i:integer;
begin
s:=0;
for i:=1 to n do
  s:=s+trunc(a[i]/m);
if s=k then find:=true
 else find:=false;
end;
procedure main;
begin
while r>=f do
 begin
  m:=(f+r)/2;
  if not find then
    begin
     if s>k then f:=f+0.001
      else r:=m;
     if abs(r-f)<0.00001 then break;
    end
   else
    begin
     if m>best then best:=m;
     if f=r then break;
     f:=f+0.001;
    end;
 end;
best:=trunc(best*100);
best:=best/100;
writeln(best:0:2);
end;
BEGIN
readdata;
main;
END.
Re: please see it? It got WA.
Послано zealot 19 ноя 2002 19:35
give some texts please.
It seemd that it must got AC
Послано I am david. Tabo. 19 ноя 2002 21:43
> give some texts please.
Here is AC. Can you help me anather programs on webboard
Послано I am david. Tabo. 19 ноя 2002 21:46
const    max    = 10000;

var      a                :array[1..max] of longint;

         n,k              :word;

         dau,cuoi,giua,
         kq               :longint;

         ok               :boolean;


procedure nhap;
var    i       :word;
       x       :real;
begin
  readln( n, k);

  for i := 1 to n do
  begin  readln( x);
         a[i] := round( x * 100);
  end;
end;


procedure cut;
var    doan     :longint;
       i        :word;
begin
  doan := 0;
  for i := 1 to n do
  begin
    doan := doan + a[i] div giua ;
    if doan >= k then break;
  end;

  ok :=  ( doan >= k );
  if ok and ( giua > kq ) then kq := giua;
end;


procedure solve;
begin
  dau := 1; cuoi := 10000000; kq := 0;

  repeat
    giua := ( dau + cuoi ) div 2;

    cut;

    if ok then dau  := giua + 1
          else cuoi := giua - 1;
  until dau > cuoi;
end;


procedure out;
var     x     :real;
begin
  x := kq;
  x := x / 100;
  writeln(x :0 :2);
end;


begin
  nhap;
  solve;
  out;
end.
It was my friends. But here is my. very little
Послано I am david. Tabo. 19 ноя 2002 21:49
uses math;
const p=3.1415926535897;
var a,r:integer;
    s,angl,cosa:real;
begin
  readln (a,r);
  if (2*r<=a) then
    s:=p*r*r
  else
    if (sqrt(2)*a/2<r) then
      s:=a*a
    else
      begin
        cosa:=a/(2*r);
        angl:=2*arccos(cosa);
        angl:=p/2-angl;
        s:=((a/2)*sqrt(r*r-(a*a)/4))+angl*r*r/2;
        s := s * 4;
      end;
   writeln (s:0:3);
end.
Something is strange!!Help!
Послано Tony 12 май 2003 18:56
My program is like yours.
But if i use a[i] := trunc( x * 100),it's WA.
And if i use a[i] := round( x * 100),it will be AC.
Is there something different from the two ways in this problem?
Isn't the input with exactly two digits after a decimal point?
It's floating error.
Послано Maigo Akisame (maigoakisame@yahoo.com.cn) 16 июл 2004 19:05