zoukankan      html  css  js  c++  java
  • C. Polygon for the Angle 几何数学

    C. Polygon for the Angle 几何数学

    题意

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

    思路

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

    #include<bits/stdc++.h>
    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<int ,int >
    #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<<i<<endl;
    				break;
    			}
    		}
    		if(!ok)
    		cout<<-1<<endl;
    	}
    	return 0;
    }
    
  • 相关阅读:
    POJ 1265 Pcik定理
    POJ 1380 坐标旋转
    POJ 1788
    POJ 3714 平面最近点对
    POJ 1905 二分
    POJ 1151 矩形面积并
    POJ 1654 多边形面积
    ZOJ 1010 判断简单多边形+求面积
    about work
    Python 打印 不换行
  • 原文地址:https://www.cnblogs.com/ttttttttrx/p/10800169.html
Copyright © 2011-2022 走看看