[恢]hdu 1408

2011-12-20 07:55:14

地址:http://acm.hdu.edu.cn/showproblem.php?pid=1408

题意:中文。

mark:输入其实是实数。。。题目没说清楚。OLE了一次,wa了好几次,都是精度惹的祸。

过了以下测试数据应该就没大问题了。

intput

10 1

11 1

1 0.1

1.1 0.1

 

output

13

15

13

15

代码:

# include <stdio.h>


int main ()
{
double vul, d ;
int i, ans ;
while (~scanf ("%lf%lf", &vul, &d))
{
for (i = 1 ; ; i++)
if (i*(i+1)/2 >= vul / d) break ;
ans = (i-1)*i/2 ;
vul -= ans*d ;
ans += (int)((vul-1e-9)/d+1) + (i-1) ;
printf ("%d\n", ans) ;
}
}



原文地址:https://www.cnblogs.com/lzsz1212/p/2315275.html