zoukankan      html  css  js  c++  java
  • icpc2018-焦作-D-几何模拟

    https://nanti.jisuanke.com/t/34142

    上午可能是供氧不足,推的式子死活不对,晚上莫名其妙又来了一次就过了。

    分两种情况讨论,如果能够完全进入弯道答案就是固定的就是: sqrt(b^2 + (a+r)^2) 

    否则的话考虑过左后方那个点做垂直y的直线,答案就是圆心到这条直线最短距离,利用已知角度d可以计算得到。

     

    红线就是答案。

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 const double PI=acos(-1.0);
     4 int main(){
     5     int a,b,r,d;
     6     int t;
     7     cin>>t;
     8     while(t--){
     9         cin>>a>>b>>r>>d;
    10         if(atan(1.0*b/(a+r))/PI*180<d){
    11             printf("%.12f
    ",sqrt(1.0*(b*b)+(a+r)*(a+r))-r);
    12         }
    13         else{
    14             double agl=d/180.0*PI;
    15             printf("%.12f
    ",-r+1.0*(a+r)*cos(agl)+sin(agl)*b);
    16         }
    17     }
    18     return 0;
    19 }
  • 相关阅读:
    token
    id
    vim
    http_proxy
    brew
    认证
    go
    linux 磁盘管理
    vmware
    vmware fusion
  • 原文地址:https://www.cnblogs.com/zzqc/p/10093732.html
Copyright © 2011-2022 走看看