HH's sick. Time limit: 1 Sec Memory Limit: MB
Submit: 324 Solved: 90
[Submit] [Status] [Web Board] Description
HH very unfortunate cold, had to go to the school hospital to hang salt water, hanging salt water, he found that the salt water dripping up a regular, first drop a drop, stop; then drop two drops, stop it, drop three more drops, stop ..., there is a problem: this bottle of salt water has vul ml, each drop is a D ml, The speed of each drop is one second (assuming that the last drop is less than D ml, then the time spent is one second), and the time of the pause is one second. When will this bottle of water be finished?
Input
The input data takes up one line, consisting of Vul and D, where 0< d< vul< 5000.
Output
Please output the time required to finish the brine.
Sample InputTen 1Sample Output -
#include <stdio.h>int main () { int i=1,ans=0,n,a,sum=0; scanf ("%d%d", &n,&a); while (1) { if (sum+i*a<n) { sum=sum+i*a; ans+=i; } else { n=n-sum; if (n%a) ans=ans+n/a+1; else ans=ans+n/a; break; } i++; ans++; } printf ("%d\n", ans); return 0;}
HH's Sick (hpu1136)