CF820A.Mister B and Book Reading
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Mister B once received a gift: it was a book about aliens, which he started read immediately. This book had c pages.
At first day Mister B read _v_0 pages, but after that he started to speed up. Every day, starting from the second, he read a pages more than on the previous day (at first day he read _v_0 pages, at second — _v_0 + a pages, at third — v_0 + 2_a pages, and so on). But Mister B is just a human, so he physically wasn't able to read more than _v_1 pages per day.
Also, to refresh his memory, every day, starting from the second, Mister B had to reread last l pages he read on the previous day. Mister B finished the book when he read the last page for the first time.
Help Mister B to calculate how many days he needed to finish the book.
米斯特·B 曾收到一份礼物:一本关于外星人的书,他立刻开始阅读。这本书共有 c 页。
第一天,米斯特·B 阅读了 v0 页;之后他开始逐渐加快阅读速度。从第二天起,他每天比前一天多读 a 页(即:第一天读 v0 页,第二天读 v0+a 页,第三天读 v0+2a 页,依此类推)。但米斯特·B 毕竟只是人类,因此他每天实际最多只能读 v1 页。
此外,为了巩固记忆,从第二天起,米斯特·B 每天都必须重读前一天最后 l 页的内容。米斯特·B 在首次读到该书最后一页时,即视为读完此书。
请帮助米斯特·B 计算他读完这本书共需要多少天。
输入格式
First and only line contains five space-separated integers: c, _v_0, _v_1, a and l (1 ≤ c ≤ 1000, 0 ≤ l < _v_0 ≤ _v_1 ≤ 1000, 0 ≤ a ≤ 1000) — the length of the book in pages, the initial reading speed, the maximum reading speed, the acceleration in reading speed and the number of pages for rereading.
第一行且仅一行包含五个以空格分隔的整数:c、v0、v1、a 和 l(1 ≤ c ≤ 1000,0 ≤ l < v0 ≤ v1 ≤ 1000,0 ≤ a ≤ 1000)——分别表示书的页数、初始阅读速度、最大阅读速度、阅读速度的加速度以及需要重读的页数。
输出格式
Print one integer — the number of days Mister B needed to finish the book.
输出一个整数——Mister B 读完这本书所需的天数。
输入输出样例
输入#1
5 5 10 5 4
输出#1
1
输入#2
12 4 12 4 1
输出#2
3
输入#3
15 1 100 0 0
输出#3
15
说明/提示
In the first sample test the book contains 5 pages, so Mister B read it right at the first day.
In the second sample test at first day Mister B read pages number 1 - 4, at second day — 4 - 11, at third day — 11 - 12 and finished the book.
In third sample test every day Mister B read 1 page of the book, so he finished in 15 days.
在第一个样例测试中,这本书共有 5 页,因此 Mister B 在第一天就读完了整本书。
在第二个样例测试中,Mister B 第一天阅读了第 1–4 页,第二天阅读了第 4–11 页,第三天阅读了第 11–12 页,并读完了整本书。
在第三个样例测试中,Mister B 每天只读 1 页,因此他用了 15 天读完这本书。
输入解题思路,AI测评打分。不知道怎么写?