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

Обсуждение задачи 1820. Уральские бифштексы

Pascal. Who could help me, please?
Послано Michael [SESC UrFU] 23 авг 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?
Послано TinyJanssen 24 авг 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?
Послано Michael [SESC UrFU] 27 авг 2013 13:15
Thanks!