ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1820. Ural Steaks

Pascal. Who could help me, please?
Posted by Michael [SESC UrFU] 23 Aug 2013 20:24
I tried this program, but there was an compilation error:

var a,b,c:integer;
begin
readln(a,b);
if a>b then c:=ceil(2*a/b) else c:=2;
write(c);
end.

I understood that, FreePascal doesn't know function ceil(). I described it like this:

function ceil(a:real):real;
begin
if frac(a)=0 then ceil:=a else ceil:=int(a)+1;
end;
var a,b:integer;
c:real;
begin
readln(a,b);
if a>b then c:=ceil(2*a/b) else c:=2;
write(c);
end.

But it doesn't work! First, why? Second, I tried an another code:

var n,k,m:integer;
begin
read(n,k);
if n>k then
if 2*n mod k=0 then m:=2*n div k
else m:=(2*n div k)+1
else m:=2;
write(m);
end.

It works! But I don't understand differences between this program and my first program! Could you help me?

Edited by author 23.08.2013 20:31
Re: Pascal. Who could help me, please?
Posted by TinyJanssen 24 Aug 2013 17:49
The function ceil returns a float.
Maybe thats thr problem

Sometimes write (c)

Writes 3.0 and not 3 as it should
Re: Pascal. Who could help me, please?
Posted by Michael [SESC UrFU] 27 Aug 2013 13:15
Thanks!