zoukankan      html  css  js  c++  java
  • LightOJ 1137

    http://www.lightoj.com/volume_showproblem.php?problem=1137

    题意:一根长度为L的杆热膨胀为L',左端点到右端点间距离不变,且膨胀后的杆的弧为圆形的一部分。

    思路:由于弧度值是固定在0~PI间,所以直接二分弧度制,通过初中学的弧度公式换算一下就行了,之前精度总是达不到要求,其实eps设的更小点就行了...

    /** @Date    : 2016-12-11-21.41
      * @Author  : Lweleth (SoungEarlf@gmail.com)
      * @Link    : https://github.com/
      * @Version :
      */
    #include<bits/stdc++.h>
    #define LL long long
    #define PII pair
    #define MP(x, y) make_pair((x),(y))
    #define fi first
    #define se second
    #define PB(x) push_back((x))
    #define MMG(x) memset((x), -1,sizeof(x))
    #define MMF(x) memset((x),0,sizeof(x))
    #define MMI(x) memset((x), INF, sizeof(x))
    using namespace std;
    
    const int INF = 0x3f3f3f3f;
    const int N = 1e5+20;
    const double eps = 1e-15;
    const double PI = acos(-1.00);
    
    
    int main()
    {
        int T;
        int cnt = 0;
        cin >> T;
        while(T--)
        {
            double l, n, c;
            cin >> l >> n >> c;
            double lx = l * (1 + n * c);
    
            double ll = 0;
            double rr = PI;
            double ans = -1;
            while(fabs(ll - rr) > eps)
            {
                double m = (ll + rr) / 2.00;
                double r = lx / m;
                double ly = 2*r * sin(m / 2);
                ans = lx / m * (1 - cos(m / 2));
                if(fabs(ly - l) < eps)
                    break;
                else if(ly < l)
                    rr = m;
                else if(ly > l)
                    ll = m;
                //cout << ly << endl;
            }
            printf("Case %d: %.9lf
    ", ++cnt, ans);
        }
        return 0;
    }
    
    
  • 相关阅读:
    css实现垂直居中
    js验证输入框
    textarea统计字数
    ajax提交form表单
    JS中的正则表达式
    《遮蔽层的隐藏块》
    2016各大互联网公司前端面试题汇总
    JQ 添加节点和插入节点的方法总结
    [原]CentOS7部署osm2pgsql
    [原]CentOS7部署PostGis
  • 原文地址:https://www.cnblogs.com/Yumesenya/p/6163271.html
Copyright © 2011-2022 走看看