首页 > 代码库 > Codeforces Round #421 A

Codeforces Round #421 A

A. Mister B and Book Reading

题意:给你一本c页的数,第一天读v0页,以后每天读 的页数比前一天多a页(v0+a,v0+2a,v0+3a), 但是每天读的页数不超过v1页,且从第二天起,每天要从前一天的后 l 页读起(也就是每天都要将前一天的后l页再读一遍),求多少天可以读完这本数

思路:xjb模拟

AC代码:

#include "iostream"
#include "string.h"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "set"
#include "map"
#include "algorithm"
#include "stdio.h"
#include "math.h"
#define ll long long
#define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
#define mem(a) memset(a,0,sizeof(a))
using namespace std;
const int N=1e5+100;
int main(){
    int c,v0,v1,a,l;
    cin>>c>>v0>>v1>>a>>l;
    int ans=0,s=0,k=v0;
    while(c>s){
        if(ans!=0) s-=l;
        ans++;
        s+=k;
        k+=a;
        if(k>v1)k=v1;
    }
    cout<<ans<<endl;
    return 0;
}

/*
5 5 10 5 4
12 4 12 4 1
15 1 100 0 0
*/

 

Codeforces Round #421 A