ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1184. Cable Master

please see it? It got WA.
Posted by zealot 19 Nov 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;
var i:integer;
begin
for i:=1 to n do
begin
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
main;
END.
Re: please see it? It got WA.
Posted by zealot 19 Nov 2002 19:35
It seemd that it must got AC
Posted by I am david. Tabo. 19 Nov 2002 21:43
Here is AC. Can you help me anather programs on webboard
Posted by I am david. Tabo. 19 Nov 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

for i := 1 to n do
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
Posted by I am david. Tabo. 19 Nov 2002 21:49
uses math;
const p=3.1415926535897;
var a,r:integer;
s,angl,cosa:real;
begin
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!
Posted by Tony 12 May 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.
Posted by Maigo Akisame (maigoakisame@yahoo.com.cn) 16 Jul 2004 19:05