Finding the Radius for an Inserted Circle 公式/几何 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛

来源:互联网 发布:淘宝助理电子单号撤销 编辑:程序博客网 时间:2024/05/20 07:35

题目链接

几何加公式题,利用余弦定理求角的余弦值,进而求解
#include<bits/stdc++.h>using namespace std;typedef long long ll;const long double pi = acos(-1.0);long double R;int k,l;long double ans[11];int main(){//    freopen("data.txt","r",stdin);//    ios_base::sync_with_stdio(false);    cin >>l>>R;    ans[1] = R/(sin(pi/3))-R;    long double ra = cos(pi/3);    long double a,b,c,x;    for(int i=2;i<=10;i++)    {        a = ans[i-1];        x = (2*a*a+2*a*R-2*a*(a+R)*ra) /(  2*((R-a)+(a+R)*ra)  )  ;        ans[i] =x;        a = ans[i-1]+R;        b = ans[i-1]+x;        c = R+x;//        cout << a<<" "<<b<<" "<<c<<endl;        ra =(c*c + b*b - a*a) / (2*b*c);        ra *= -1;    }    for(int i=0;i<l;i++)    {        cin >> k;        cout <<k<<" "<<(ll)ans[k]<<endl;    }    cin >> k;    return 0;}
阅读全文
0 0
原创粉丝点击