首页 > 技术文章 > codeforces 820A. Mister B and Book Reading 解题报告

windysai 2017-06-28 23:35 原文

题目链接:http://codeforces.com/problemset/problem/820/A

坑爹题目,坑爹题目,坑爹题目。。。。汗 = =!  后台还110个 test

  有个地方需要注意下

  当 第 i 天看的页数超过 v1的时候,第 i 天及以后每天都是看 v1 页;然后不要以为 l 是没有用的(我一开始就sb地以为是没有用的),从第 2 天开始,就要每天倒退 l 页

  

 1 #include <cstdio>
 2 #include <cstdlib>
 3 #include <cstring>
 4 #include <algorithm>
 5 #include <iostream>
 6 using namespace std;
 7 
 8 int main(){
 9     #ifndef ONLINE_JUDGE
10        freopen("in.txt", "r", stdin);
11     #endif // ONLINE_JUDGE
12 
13     int c, v0, v1, a, l;
14     while(scanf("%d%d%d%d%d", &c, &v0, &v1, &a, &l) != EOF) {
15         int day = 1;
16         int readed = v0;
17 
18         while (readed < c) {
19             int tmp = min(v1, v0 + a*day);   // change
20             readed += tmp;
21             day++;
22             readed -= l;
23         }
24         printf("%d\n", day);
25 
26     }
27     return 0;
28 }

 

  

 

推荐阅读