POJ 1905 Expanding Rods 二分答案几何

题目:http://poj.org/problem?id=1905

恶心死了,POJ的输出一会要lf,一会要f,而且精度1e-13才过,1e-12都不行,错了一万遍终于对了。

 #include <stdio.h>
#include <math.h> int main()
{
double l, n, c, r;
while(scanf("%lf %lf %lf", &l, &n, &c) != EOF)
{
if(l < && n < && c < )break;
double arc = ( + n*c) * l;
double low = , high = acos(-1.0) / ;
while(high-low > 1e-)
{
double mid = (high+low) / ;
r = l/ / sin(mid);
if(r * mid < arc / )
{
low = mid;
}
else
{
high = mid;
}
}
printf("%.3lf\n", r-r*cos(low));
}
return ;
}
上一篇:linux Java项目CPU内存占用高故障排查


下一篇:POJ - 1905 Expanding Rods(二分+计算几何)