C. Polygon for the Angle 几何数学

C. Polygon for the Angle 几何数学

题意

给出一个度数 ,问可以实现的最小的n的n边形是多少

思路

由n边形的外角和是180度直接就可以算出最小的角是多少 如果给出的度数是其最小角的倍数并且在这个n边形最大度数之内,那么就可以得到了 直接从小到大枚举n边形即可

#include
using namespace std;
const int maxn = 3e5+5;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define pii pair
#define mkp make_pair
#define int double
const int inf=0x3f3f3f3f;
int32_t main(){
    int t,ang;
    int ok=0;
    scanf("%lf",&t);
    while(t--){
        ok=0;
        scanf("%lf",&ang);
        int k;
        for(int i=3;i<=1000000;i++){
          k=ang/((180-360/i)/(i-2));
          if(ang<=180-360/i&&k==int32_t(k))
            {
                ok=1;
                cout<

转载于:https://www.cnblogs.com/ttttttttrx/p/10800169.html

你可能感兴趣的:(C. Polygon for the Angle 几何数学)