• Codeforces Round #421 B


    B. Mister B and Angle in Polygon

    题意:给你一个正n边形(每个点顺时针依次为1 2 3...n),一个角度a,从多边形中任选3个点A B C 求最接近a的角ABC 输出ABC

    思路:将n多边形外接一个圆,可知,当2个点确定的时候,角度就已经确定了(只考虑小于180度的情况),所以,确定一个点之后暴力另一个点就可以求得所有情况了(注意只要暴力到n-2就可以了)

    AC代码:

    #include "iostream"
    #include "string.h"
    #include "stack"
    #include "queue"
    #include "string"
    #include "vector"
    #include "set"
    #include "map"
    #include "algorithm"
    #include "stdio.h"
    #include "math.h"
    #define ll long long
    #define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
    #define mem(a) memset(a,0,sizeof(a))
    using namespace std;
    const int N=1e5+100;
    int n,a;
    double an,an1,ab=365,ans;
    int main(){
        cin>>n>>a;
        for(int i=1; i<n-1; ++i){
            an=180.0*i/n;
            if(fabs(an-a)<ab){
                ab=fabs(an-a);
                ans=i+1;
            }
        }
        if(ans==2) cout<<"1 3 "<<ans;
        else cout<<"1 "<<ans+1<<" "<<ans;
        return 0;
    }
    
    /*
    3 15
    4 67
    4 68
    */
  • 相关阅读:
    2019/1/2
    2018/12/22
    2018/12/18
    2018/12/17
    2018/12/16
    编程总结汇总
    学习总结汇总
    第十三周学习总结--助教
    第十一周编程总结
    第10周编程总结
  • 原文地址:https://www.cnblogs.com/max88888888/p/7091939.html
Copyright © 2020-2023  润新知