Hiển thị các bài đăng có nhãn brute force. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn brute force. Hiển thị tất cả bài đăng

Thứ Năm, 3 tháng 1, 2019

Codeforces Round 57- Bài 3


Bài 3: You are given an angle $ang$
the Jury asks You to find such regular $n-gon$( regular polygon with $n$ vertices) that it has three vertices $a,b$ and $c$( they can be non-consecutive) with $\angle{abc}=ang$ or report that there is no such $n-gon$

If there are several answers, print the minimal one. It is guarantied that if answer exists then it doesn't exceed $998244353$
Input
The first line contains single integer $T(1\le T\le 180)$- the number of queries.
Each of the next $T$ lines contains one integer $ang(1\le ang<180)$— the angle measured in degrees.
Output
For each query print single integer $n(3\le n<998244353)$- minimal possible number of vertices in the regular $n-gon$ or $-1$ if there is no such $n$
Example
input
Copy
4
54
50
2
178
output
Copy
10
18
90
180
Solution: 
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,g,t;
cin>>t;
for(int i=0;i<t;i++){
cin>>n;
g=__gcd(n,180);
int k=n/g;
n=180/g;
if(k==n-1){n*=2;}cout<<n<<endl;
}}

Bài G - Educatioal Round 62

Đề bài: Bạn được cho 1 đồ thị vô hướng đặc biệt. Nó bao gồm $2n$ đỉnh được đánh số từ 1 đến 2n. Dưới đây là một số đặc tính của đồ thị: + ...