(为什么觉得越来越不行了,唉~果然脑子不够使啊~)
http://acm.hdu.edu.cn/showproblem.php?pid=1408
分析:
简单的模拟,不过学习了使用了ceil(double x) 函数 (math.h)
double ceil(double x) (天花板函数)
返回大于或者等于指定表达式的最小整数
double floor( double x ) (地板函数)
函数返回参数不大于
x
的最大整数
代码:
//1408
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
int ans;
double v,d,dd; //不用double wa 虽然用了ceil(1.0*v/d)
while(cin>>v>>d){
dd=ceil(v/d);
ans=dd; //每滴水的时间一定要算的
//cout<<dd<<endl;
for(int i=1;;i++){ //间隔的时间
dd -=i;
if(dd>0) ans++;
else break;
}
cout<<ans<<endl;
}
}