http://codeforces.com/contest/1096/problem/C
C. Polygon for the Angle
input
standard input
output
standard output
You are given an angle angang.
The Jury asks You to find such regular nn-gon (regular polygon with nn vertices) that it has three vertices aa, bb and cc (they can be non-consecutive) with ∠abc=ang∠abc=ang or report that there is no such nn-gon.
If there are several answers, print the minimal one. It is guarantied that if answer exists then it doesn't exceed 998244353998244353.
Input
The first line contains single integer TT (1≤T≤1801≤T≤180) — the number of queries.
Each of the next TT lines contains one integer angang (1≤ang<1801≤ang<180) — the angle measured in degrees.
Output
For each query print single integer nn (3≤n≤9982443533≤n≤998244353) — minimal possible number of vertices in the regular nn-gon or −1−1 if there is no such nn.
Example
input
Copy
4 54 50 2 178
output
Copy
10 18 90 180
Note
The answer for the first query is on the picture above.
The answer for the second query is reached on a regular 1818-gon. For example, ∠v2v1v6=50∘∠v2v1v6=50∘.
The example angle for the third query is ∠v11v10v12=2∘∠v11v10v12=2∘.
In the fourth query, minimal possible nn is 180180 (not 9090).
都是英语,他娘的,什么也看不懂
这道题的意思是:有一个正n边形,选取三个点,确定一个圆周角,然后求n最小为多少
这道题,,,真基尔操蛋
我们可以这么看: 首先,要求出圆周角对应的圆心角的大小:
如果圆周角>=90度:如图:
那么圆心角=(180度—圆周角)*2;
如果圆周角小于90度,圆心角=圆周角*2;如图:
int g;///圆周角
scanf("%d",&g);
int fa=1;
if(g>=90)
{
g=180-g;
fa=2;
}
g=g*2;///圆心角
然后设该圆心角对应n边形中x条边
接下来求x:
如果输入的圆周角>=90度那么,x>=2
否则,x>=1;
然后开始遍历
int flag=-1;///是否找到了符合条件的x
for(int x=fa;x<=g;x++)
{
if(g%x==0)将圆心角分为x份,如果能份完
{
int y=g/x;///每份所对应的圆心角
if(360%y==0)///如果360度是圆心角的倍数,就说明符合条件
{
flag=x;
break;
}
}
}
最后输出:
if(flag==-1)
{
printf("-1");
}
else {
printf("%d\n",360/(g/flag));
}
#include<string.h>
#include<stdio.h>
#include<math.h>
#define ll long long
#define mod 998244353
int main()
{
ll t;
scanf("%lld",&t);
while(t--)
{
int g;///圆周角
scanf("%d",&g);
int fa=1;
if(g>=90)
{
g=180-g;
fa=2;
}
g=g*2;
int flag=-1;///是否找到了符合条件的x
for(int x=fa;x<=g;x++)
{
if(g%x==0)
{
if(360%(g/x)==0)
{
flag=x;
break;
}
}
}
if(flag==-1)
{
printf("-1");
}
else {
printf("%d\n",360/(g/flag));
}
}
return 0;
}