【Codeforces Round #421 (Div. 2) B】Mister B and Angle in Polygon

【题目链接】:http://codeforces.com/contest/820/problem/B

【题意】

给你一个正n边形;
然后让你在这正n边行中选3个点,组成一个角;
找出角的大小和所给的角最接近的角;

【题解】

同弧所对应的圆周角都是相同的;
而且每个正多边行都能作出一个外接圆;
所以随便选两个相邻的点;然后再选其他
n-2个点中的一个点组成角;
就能覆盖到所有的情况了;
顺序增加角的大小就好(一份一份地加);

【Number Of WA

0

【反思】

想说是B题;
就没往复杂的地方想了.

【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 110;

int n,c;
double a,d;

int main(){
    //Open();
    Close();
    cin >> n >> a;
    double t = (n-2)*180/(1.0*n);
    t=t/(1.0*(n-2));
    double now = t;
    int temp = n;
    rep1(i,1,n-2){
        if (i==1){
            c = temp;
            d = fabs(now-a);
        }else{
            double temp1 = fabs(now-a);
            if (temp1 < d){
                d = temp1;
                c = temp;
            }
        }
        temp--;
        now+=t;
    }
    cout << 1 <<' '<<2<<' '<<c<<endl;
    return 0;
}
posted @ 2017-10-04 18:44  AWCXV  阅读(303)  评论(0)    收藏  举报