Cheerio Contest 2 P2 - Cereal Boxes
View as PDFFarmer Bob is buying cereal boxes at his local grocery store, which are priced in the following way:
- The first 
cereal boxes cost
dollars each
 - For every 
boxes purchased, the price of any subsequent boxes is increased by
dollars
 
Bob only has  dollars to spend. What is the maximum number of cereal boxes he can buy?
Constraints
For all subtasks:
Input Specification
The only line of input contains four integers , 
, 
 and 
.
Output Specification
Output the maximum number of cereal boxes Bob can buy.
Sample Input 1
2 1 3 35
Sample Output 1
7
Explanation for Sample 1
The prices of the cereal boxes Bob can buy are , 
, 
, 
, 
, 
 and 
 dollars respectively.
Sample Input 2
1 15 1 10
Sample Output 2
0
Comments