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

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

c++ Accepted answer(efficient and simple to understand)+explanation
Послано Lawrence 23 июн 2014 18:37
[code deleted by moderator]

You are interested in the number of sides, not steaks as total. First you calculate number of sides, then you calculate the remainder between it and the maximum number of steaks that can be cooked in 1 minute. If the remainder is bigger than 1(not equal, if equal you will get wrong answer ex: 7 and 4 yields answer 3 with actually is 4) then you write the number of sides divided by the maximum number(of sides) in the pan plus the extra that remains. Else you do the same without adding the extra. If k>n, then the maximum is 2 minutes(1 minute for each side) because all steaks fit in the pan. It's a simple and quick solution. Some examples:
1. 4 steaks and maximum 3 in a pan. You have 8 sides and a maximum of 3 in a pan. 8%3=1, that means that you have 2 sides extra. Answer is 8/3 + 1 =3
2. 7 steaks and maximum 4 in a pan. You have 14 sides and maximum 4 in a pan. 14%4=2, that is why you need to put 2*n%k>=1 and not 2*n%n==1. The answer is 14%4 + 1 =3+1=4
I hope that it helped!

Edited by moderator 21.07.2014 01:04
Re: c++ Accepted answer(efficient and simple to understand)+explanation
Послано mhg 7 июл 2014 17:57
thanks.

Edited by author 07.07.2014 18:01
Re: c++ Accepted answer(efficient and simple to understand)+explanation
Послано Gefest 19 окт 2014 06:37
Thanks, realy helped.