天天看点

1135:盐水的故事

1135:盐水的故事

Description

挂盐水的时候,如果滴起来有规律,先是滴一滴,停一下;然后滴二滴,停一 下;再滴三滴,停一下...,现在有一个问题:这瓶盐水一共有VUL毫升,每一滴是D毫升,每一滴的速度是一秒(假设最后一滴不到D毫升,则花费的时间也 算一秒),停一下的时间也是一秒这瓶水什么时候能挂完呢?

Input

输入数据占一行,由VUL和D组成,其中0< D< VUL< 5000。

Output

请输出挂完盐水需要的时间

SampleInput

10  1

Sample Output

13

#include<iostream>
using namespace std;
int main()
{
 
    int VUL,D,count,i,temp=1;
    cin>>VUL>>D;
  count=D;
  for(i=2;i<10000;i++)
  {
      temp=temp+1;
      for(int j=1;j<=i;j++)
      {
         temp=temp+1;
         count=count+D;
         if(count>=VUL)
         {
             cout<<temp;
           return 0;
         }
      }
  }
 
}
           

继续阅读