Polygon for the Angle 1096C(圆心角与圆周角)

只要知道圆心角与圆周角的关系即可

圆心角=2×圆周角

因为该题是正n边形,每个点到中心的距离相等,即可把这n个点放在圆周上

确定两个点一条边,还可以与剩下的n-2个点形成角度。

每个角度即是圆心角的1/2.

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <map>
#include <cstring>
using namespace std;
typedef long long ll;
int edge[200];
void init(){
    memset(edge,0,sizeof(edge));
    for(int i=3;i<=360;i++){
        double newang = 180.0/(1.0*i);
        for(int j=1;j <= i-2; j++){
            double k = newang*j*1.0;
            if((int)k != k)
                continue;
            int kk = k;
            if(edge[kk] == 0)
                edge[kk] = i;
        }
    }
}
int main(){
    int t,ang;
    init();
//    for(int i=1;i<=180;i++)
//        printf("%d %d
",i,edge[i]);
    scanf("%d",&t);
    while(t--){
        scanf("%d",&ang);
        if(edge[ang])
        printf("%d
",edge[ang]);
        else
        printf("-1
");
    }
    return 0;
}
原文地址:https://www.cnblogs.com/LLLAIH/p/10888476.html