codeforces round #236 div.2 A

题目链接:http://codeforces.com/contest/402/problem/A

第一次做codeforces。第一道水题,没什么算法,直接贴代码。

 1 ///2014.3.16
 2 ///codeforces round #236 div.2
 3 ///A
 4 
 5 #include <cstdio>
 6 #include <iostream>
 7 using namespace std;
 8 
 9 int main()
10 {
11     int k,a,b,v;
12     scanf("%d%d%d%d",&k,&a,&b,&v);
13     int n = 0;
14     while( a>0 ){
15         if( b>=k-1 ){
16             b -= k-1;
17             a -= k*v;
18             n++;
19         }
20         else if( b>0 ){
21             a -= (b+1)*v;
22             b = 0;
23             n++;
24         }
25         else{
26             a -= v;
27             n++;
28         }
29     }
30     printf("%d",n );
31     return 0;
32 }

 

posted @ 2014-03-20 21:17  basement_boy  阅读(158)  评论(0)    收藏  举报