I am to find if any given angle(say x)can be interior angle of regular polygon.In other words,is there a regular polygon which angles are equal to X.
I know the formula for sum of interior angles of polygon i.e (n-2)*180. I tried looping from sides 3 to 10000 and pushing back ((n-2)*180)/n and after this pre-computation i tried searching each given angles.Please see code if not clear
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
vector<int>v;
for(int i=3;i<=1000;i++)
v.push_back(((180)*(i-2))/(i));
while(t--)
{
int a;
cin>>a;
if(find(v.begin(),v.end(),a)!=v.end())
puts("YES");
else
puts("NO");
}
return 0;
}
This is giving correct answer for some values but not all.
Is there any better(geometrical way) to do this ?
EDIT:-
I have seen the solution and it was something like true if (360%(180-x)==0) else false.I still can't get it(why 360%(180-x).Anybody please explain this or give different way
v.push_back(((180)*(i-2))/(i));
should bev.push_back(((180)*(i-2))/double(i));
$\endgroup$