zoukankan      html  css  js  c++  java
  • poj1905

    题意:给出膨胀指数,加热温度,杆子的原长度,问加热后的杆子两端点位置不变,弯曲成弧,圆心的位置。

    分析:二分答案,二分查找圆心位置,根据圆心位置计算出弧长与原弧长比较,不知道为什么wa那么多次。

    View Code
    #include <iostream>
    #include
    <cstdio>
    #include
    <cstdlib>
    #include
    <cstring>
    #include
    <cmath>
    usingnamespace std;

    #define eps 1.0e-8

    double c, l1, n;

    double cal(double b)
    {
    double a = l1 /2;
    double d = sqrt(a * a + b * b);
    double h = a * d / b;
    double r = sqrt(h * h + d * d) /2;
    return atan(b / (l1 /2)) *4* r;
    }

    int main()
    {
    //freopen("t.txt", "r", stdin);
    while (scanf("%lf%lf%lf", &l1, &n, &c) != EOF)
    {
    if (n <0&& l1 <0&& c <0)
    break;
    double l2 = l1 * (n * c +1);
    if (l2 - l1 < eps)
    {
    printf(
    "0.000\n");
    continue;
    }
    double l = eps;
    double r = l1 /2;
    double mid;
    while (abs(l - r) > eps)
    {
    mid
    = (l + r) /2;
    double x = cal(mid);
    if (abs(x - l2) < eps)
    break;
    if (x > l2)
    r
    = mid - eps;
    else
    l
    = mid + eps;
    }
    printf(
    "%.3f\n", mid);
    }
    return0;
    }
  • 相关阅读:
    Neo4j-3.0.3 (Debian 8)
    python学习之argparse模块
    变异系数
    孪生素数
    统计学中的自由度
    兰伯特余弦定理(Lambert)
    椒盐噪声
    沥青路面磨损后泛白的原因
    朗伯体
    绕坐标轴旋转的矩阵
  • 原文地址:https://www.cnblogs.com/rainydays/p/2096471.html
Copyright © 2011-2022 走看看