题目
{% fold 点击显/隐题目 %}
At first day Mister B read v0 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 v0 pages, at second — v0?+?a pages, at third — v0?+?2a pages, and so on). But Mister B is just a human, so he physically wasn't able to read more than v1 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.
题解
题意
一本有c
页的书,第一天读v0
页,每天比前一天多读a
页(最多不超过v1
)
同时每天需要复习前一天读过的l
页
问需要几天读完需要多久
需要注意的是第一天是不需要复习前一天的内容的
代码
{% fold 点击显/隐代码 %}```cpp Mister B and Book Reading https://github.com/OhYee/sourcecode/tree/master/ACM 代码备份
//
#define debug
#include
//
#include
#include
#include
using namespace std;
int main() {
#ifdef debug
freopen("in.txt", "r", stdin);
int START = clock();
#endif
cin.tie(0);
cin.sync_with_stdio(false);
int c, v0, v1, a, l;
while (cin >> c >> v0 >> v1 >> a >> l) {
int ans = 0;
int hr = 0;
while (hr < c) {
if(ans)
hr -= l;
v0 = min(v0, v1);
hr += v0;
ans++;
v0 += a;
}
cout << ans << endl;
}
#ifdef debug
printf("Time:%.3fs.\n", double(clock() - START) / CLOCKS_PER_SEC);
#endif
return 0;
}
{% endfold %}