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;
}
}
}
}