zoukankan      html  css  js  c++  java
  • 09:膨胀的木棍 (二分+角度计算)

    总时间限制: 
    1000ms
     
    内存限制: 
    65536kB
    描述

    当长度为L的一根细木棍的温度升高n度,它会膨胀到新的长度L'=(1+n*C)*L,其中C是热膨胀系数。

    当一根细木棍被嵌在两堵墙之间被加热,它将膨胀形成弓形的弧,而这个弓形的弦恰好是未加热前木棍的原始位置。

    你的任务是计算木棍中心的偏移距离。

    输入
    三个非负实数:木棍初始长度(单位:毫米),温度变化(单位:度),以及材料的热膨胀系数。
    保证木棍不会膨胀到超过原始长度的1.5倍。
    输出
    木棍中心的偏移距离(单位:毫米),保留到小数点后第三位。
    样例输入
    1000 100 0.0001
    样例输出
    61.329
    来源
    Waterloo local 2004.06.12
    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <string>
    #include <cstring>
    #include <cstdlib>
    #include <map>
    #include <vector>
    #include <set>
    #include <queue>
    #include <stack>
    #include <cmath>
    using namespace std;
    #define mem(s,t) memset(s,t,sizeof(s))
    #define pq priority_queue
    #define pb push_back
    #define fi first
    #define se second
    #define ac return 0;
    #define ll long long
    #define rep(xx,yy) for(int i=xx;i<=yy;i++)
    #define TLE std::ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);   cout.precision(10);
    const double eps = 1e-14;
    string str;
    int main()
    {
        TLE;
        double l,c,t;
        while(cin>>l>>t>>c)
        {
            double mx = l*(1+t*c);
            double left = 0 ,right = asin(1.0);
            while(left + eps < right )
            {
                double mid = (left+right)/2.0;
                if(mx*sin(mid)/mid<=l)
                    right = mid;
                else
                    left = mid;
            }
            printf("%.3lf
    ", l/2*tan(left/2));
        }
        return 0;
    }
    所遇皆星河
  • 相关阅读:
    Centos安装Nginx过程步骤详细解析
    查看是否已经安装nginx
    使用uwsgi --http :80 --wsgi-file test.py 在浏览器上无法访问
    uwsgi 常用参数
    Python生成requirements.txt方法
    快排
    绝对路径和相对路径
    perspective结合transform的3D效果
    mobile&nbsp;web&nbsp;手机开发
    Date对象需要注意的点
  • 原文地址:https://www.cnblogs.com/Shallow-dream/p/11710001.html
Copyright © 2011-2022 走看看