zoukankan      html  css  js  c++  java
  • 2016-2017 CT S03E06: Codeforces Trainings Season 3 Episode 6 The Baguette Master

    比赛看不懂
    之后不确定题意去瞄了题解,需要分类讨论?囧
    之后按照队友已经ac的题意
    就是求外面一圈周长,直接可以求得

    #include<bits/stdc++.h>
    using namespace std;
    #define sz(X) ((int)X.size())
    typedef long long ll;
    const int INF = 0x3f3f3f3f;
    const int N = 3e5+5;
    const double pi = acos(-1.0);
    const double eps = 1e-6;
    
    int w;
    int a,b,c,d,e;
    double B,C1,C2,A1,A2,D;
    int sgn(double x) {
        if(fabs(x) < eps) return 0;
        else if(x < 0) return -1;
        else return 1;
    } 
    double solve(double an) {
        if(sgn(an - 2*pi) == 0) return 0;
        else {
            an /= 2;
            double ans = 0;
            ans += 2*w / tan(an);
            return ans;
        }
    }
    
    int main(){
        while(~scanf("%d",&w)) {
            double ans = 0;
            scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
            ans = a+b+c+d;
        //  printf("%.3f
    ",ans);
    
            B = acos( (a*a+b*b-e*e)*1.0 / (2*a*b) );
            C1 = acos( (b*b+e*e-a*a)*1.0 / (2*b*e) );
            A1 = acos( (a*a+e*e-b*b)*1.0 / (2*a*e) );
    
            D = acos( (c*c+d*d-e*e)*1.0 / (2*c*d) );
            C2 = acos( (c*c+e*e-d*d)*1.0 / (2*c*e) );
            A2 = acos( (e*e+d*d-c*c)*1.0 / (2*e*d) );
    
            ans += solve(B) + solve(C1+C2) + solve(A1+A2) + solve(D);
    
            printf("%.3f
    ",ans);
        }
        return 0;
    }
    
  • 相关阅读:
    219. Contains Duplicate II
    189. Rotate Array
    169. Majority Element
    122. Best Time to Buy and Sell Stock II
    121. Best Time to Buy and Sell Stock
    119. Pascal's Triangle II
    118. Pascal's Triangle
    88. Merge Sorted Array
    53. Maximum Subarray
    CodeForces 359D Pair of Numbers (暴力)
  • 原文地址:https://www.cnblogs.com/Basasuya/p/8433731.html
Copyright © 2011-2022 走看看