zoukankan      html  css  js  c++  java
  • #421(div2)A. Mister B and Book Reading

                                  A. Mister B and Book Reading

    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.

    Input

    First and only line contains five space-separated integers: c, v0, v1, a and l (1 ≤ c ≤ 1000, 0 ≤ l < v0 ≤ v1 ≤ 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.

    Output

    Print one integer — the number of days Mister B needed to finish the book.

    Examples
    Input
    5 5 10 5 4
    Output
    1
    Input
    12 4 12 4 1
    Output
    3
    Input
    15 1 100 0 0
    Output
    15
    Note

    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.

    题意:C,V0,V1,A,L。.总共有C页书,第一天以V0速度读,每天加A,但是不能超过V1,并且要从前一天的看到的当前页数的前L页开始读

    思路:模拟

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 
     4 int main(){
     5     int c,v0,v1,a,l;
     6     cin>>c>>v0>>v1>>a>>l;
     7     int sum=0;
     8     if(v0>v1) v0=v1;
     9     for(int i=1;;i++){
    10         if(v0>v1) v0=v1;
    11         sum+=v0; v0+=a;
    12         if(sum>=c) {
    13             cout<<i<<endl;return 0;
    14         }
    15         sum-=l;
    16     }
    17 }
  • 相关阅读:
    网络分析(二)定向与非定向
    Flex 找不到html文件,不能自动生成html问题解决
    常用的功能点记录
    git常规操作命令整理
    语境驱动测试7原则
    探索式测试的问与答
    测试建模:Google ACC
    探索式测试:基于测程的测试管理(SessionBased Test Management)
    用Excel展示SQL Server中的数据 (III): IronPython与自动化
    在Ajax中使用Flash实现跨域数据读取
  • 原文地址:https://www.cnblogs.com/hhxj/p/7090209.html
Copyright © 2011-2022 走看看