题目

{% fold 点击显/隐题目 %}

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 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.

First and only line contains five space-separated integers: c, v0, v1, a and l (1?≤?c?≤?1000, 0?≤?l?
Print one integer — the number of days Mister B needed to finish the book.
5 5 10 5 4 12 4 12 4 1 15 1 100 0 0
1 3 15
{% endfold %}

题解

题意
一本有 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 %}