Hangzhou Electric HDU ACM 1408 Salt water Story

Source: Internet
Author: User

The story of Brine Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 14657 Accepted Submission (s): 3555


Problem description Hang brine when, if drip up to have regular, first drop a drop, stop, then drop two drops, stop for a moment, drop three drops, stop ..., now there is a problem: this bottle of salt water has a total of 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 data contains multiple test instances, one row per instance, consisting of Vul and D, where 0<d<vul<5000.

Output for each set of test data, export the time required to suspend the brine, and the output of each instance takes up one row.

Sample Input
10 1

Sample Output
13

Authorlcy Ah Ah! Salt water droplets Story Oh! The topic is not difficult, the key is to read the topic description. Drop one drop at a time, stop, drop two drops, stop, third drop, stop for a second ——............ It means that the number of drops between two or three drops does not stop, so it can be called a continuous drip of three times. Altogether Vul ml, each drops assumes the D ml, then when the nth time successive drops, the total ml number is sn=nd (n+1)/2 Then the total droplet number is vul divided by d+n-1 a stop time, the gas dead me, on craved fart matter to forget good assembly son. AC Code:
#include <iostream> #include <cmath>using namespace Std;int main () {double Vul,d;int n;while (Cin>>vul >>d) {for (n=1;n*d* (n+1) <vul*2;n++); Cout<<ceil (vul/d) +n-1<<endl;} return 0;}

Hangzhou Electric HDU ACM 1408 Salt water Story

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.