1136:hh's sick. Time limit: 1 Sec Memory Limit: MB
Submit: 324 Solved: 90
[Submit] [Status] [Web Board] [Edit] 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 -HINT
Source
The fifth annual ACM Program Design Competition of Henan University of Technology
WA took 12 times. Almost collapsed-_-!
#include <stdio.h> #include <string.h> #include <math.h> int main () { double V, D; int A, b, ans, I, J; while (scanf ("%lf%lf", &v, &d)! = EOF) { a = v/d; if (V-A * D > 0.0) ++a; for (i = 1, ans = A; a > 0; ++i) { A-= i; if (a > 0) ++ans; } printf ("%ld\n", ans); } return 0; }/************************************************************** problem:1136 user:changmu Language:c result:accepted time:0 Ms memory:768 KB *********************************************** *****************/
HPU1136 hh Sick of "pit"