uva 375 - Inscribed Circles and Isosceles Triangles
错了好几次,因为在定义pi的时候直接标释成了3.1415926,不能直接标释成这个,要用到反三角函数,注意这点
View Code
#include<stdio.h> #include<math.h> const double pi = acos(-1.0); int main() { double b, h, r, t, _h, y; int T; scanf("%d",&T); while(T--) { scanf("%lf%lf",&b,&h); y = sqrt(h*h+b*b/4); t = b/(b+2*y); _h = h; r = t*_h; while(r >= 0.000001) { _h = _h-2*r; r = _h*t; } printf("%13.6lf\n",pi*(h-r/t)); if(T)putchar('\n'); } }