标签:
#include <iostream> #include <cstdlib> #include <cstdio> #include <cmath> using namespace std; int main() { double L,n,C,R; while (~scanf("%lf%lf%lf",&L,&n,&C)) { if (L < 0 && n < 0 && C < 0) break; double S = (1+n*C)*L; double mid,l = 0.0,r = 0.5*L; while (r-l > 1e-6) { mid = (l+r)/2.0; R = (4*mid*mid+L*L)/8.0/mid; if (2*R*asin(L/R/2.0) < S) l = mid; else r = mid; } printf("%.3lf\n",mid); } return 0; }
设升高h,则有:R^2 = (0.5L)^2 + (R-h)^2;
设弧长s,则有:s = 2*r*arcsin(L/(2R));
然而我看见了显然 画一下图可以很容易推出公式,设圆弧扇形部弧度r,那么可以计算出铁棒长度为lr/sin(r)
#include <cstdio> #include <cstring> #include <cmath> const double pi = acos(-1.0); double l, n, c; double cal(double r) { return l / sin(r) * r; } int main() { while (~scanf("%lf%lf%lf", &l, &n, &c)) { if (l < 0) break; double x = 0, y = pi / 2, lx = (1 + n * c) * l, m; for (int i = 0; i < 100; i++) { m = (x + y) / 2; if (cal(m) < lx) x = m; else y = m; } printf("%.3lf\n", l / 2 / sin(m) * (1 - cos(m))); } return 0; }
标签:
原文地址:http://www.cnblogs.com/yifi/p/4547573.html