A11003 | Mister B and Book Reading
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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}+2a$ 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.
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}+2a$ 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.
输入格式
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.
输出格式
Print one integer — the number of days Mister B needed to finish the book.
输入输出样例
输入 #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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted