Description
You have a nuts and lots of boxes. The boxes have a wonderful feature: if you put x(x ≥ 0) divisors (the spacial bars that can divide a box) to it, you get a box, divided into x + 1 sections.
You are minimalist. Therefore, on the one hand, you are against dividing some box into more than k sections. On the other hand, you are against putting more than v nuts into some section of the box. What is the minimum number of boxes you have to use if you want to put all the nuts in boxes, and you have b divisors?
Please note that you need to minimize the number of used boxes, not sections. You do not have to minimize the number of used divisors.
Input
The first line contains four space-separated integers k, a, b, v (2 ≤ k ≤ 1000; 1 ≤ a, b, v ≤ 1000) — the maximum number of sections in the box, the number of nuts, the number of divisors and the capacity of each section of the box.
Output
Print a single integer — the answer to the problem.
Sample Input
3 10 3 3
2
3 10 1 3
3
100 100 1 1000
1
Hint
In the first sample you can act like this:
In the end we've put all the ten nuts into boxes.
The second sample is different as we have exactly one divisor and we put it to the first box. The next two boxes will have one section each.
本来水题我是不打算写题解的,然而这题。。。只能说自己傻逼。。。。。
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> using namespace std; const int maxn=1000100; const int INF=(1<<29); int k,a,b,v; int main() { while(cin>>k>>a>>b>>v){ int cur=0; for(int i=1;;i++){ int cnt=1; cur+=v; while(b){ if(cnt==k) break; cur+=v; b--; cnt++; } if(cur>=a){ cout<<i<<endl; break; } } } return 0; }