Problem:
 Score : 200 points    Problem Statement Takahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times:   Go one meter in the direction he is facing. Then, turn X degrees counter-clockwise.       Constraints  1 \leq X \leq 179  X is an integer.         Input Input is given from Standard Input in the following format:  X       Output Print the number of times Takahashi will do the action before he is at the starting position again.        Sample Input 1 90      Sample Output 1 4  Takahashi's path is a square.       Sample Input 2 1      Sample Output 2 360

Solution (Python):
import math 
c = int(input())
a = 90
x,y = 0,0
e = 0.000000001

k = 1
x = math.sin(math.radians(a))
y = math.cos(math.radians(a))
while (x < -e or x > e or y < -e or y > e):
  a += c
  x += math.sin(math.radians(a))
  y += math.cos(math.radians(a))
  k += 1
print(k)

Solution (Python):
x = int(input())
ans = 0
cnt = 0
while (True):
  ans += x
  cnt += 1
  if ans % 360 == 0:
  	break
print(cnt)

Solution (Python):
X = int(input())
sum = 0
ans = 0
while(True):
    sum += X
    ans += 1
    if(sum % 360 == 0):
        print(ans)
        break

Solution (Python):
x=int(input())
i=1

while (x*i)%360!=0:
  i=i+1

print(i)

Solution (Python):
X = int(input())

for n in range(1,X+1):
    if 360*n % X == 0:
        ans = 360*n / X
        break
print(int(ans))

Solution (Python):
X = int(input())
for i in range(360):
  if X * (i + 1) % 360 == 0: 
    print(i + 1)
    break

Solution (Python):
REN = int(input())
i = 1
solve = 0
while True:
  if (360*i)%REN == 0:
    break
  else:
    i+=1
    
print(int((360*i)/REN))

Solution (Python):
import math as m
x = int(input())
print(int(360/m.gcd(360,x)))

Solution (Python):
x = int(input())
num = x
cnt = 1
while num != 0:
  num += x
  num %= 360
  cnt += 1

print(cnt)

Solution (Python):
X=int(input())

for i in range(1,10**9):
  if (i*X)%360==0:
    print(i)
    break

Solution (Python):
N = int(input())
all = 360
while all%N != 0:
    all += 360
print(all//N)

Solution (Python):
import math


x = int(input())
ans = x * 360 // math.gcd(x, 360)
print(ans // x)

Solution (Python):
import copy
X = input()
X = int(X)
A = copy.deepcopy(X)

i = 2

if 360 % X == 0:
    K = 360 / X
    K = int(K)
    print(K)
else:
    while True:
        X = copy.deepcopy(A)
        X *= i
        if X % 360 == 0:
            break
        i = i+1

    print(i)

Solution (Python):
X=int(input())
p=360
cnt=0

while p%X !=0:
    p += 360

print(p//X)

Solution (Python):
x=int(input())
if 360%x==0:
    print(360//x)
else:
    i=360
    ans=0
    while True:
        ans+=i//x
        if i%x==0:
            print(ans)
            break
        i=360+i%x

Solution (Python):
import math
X=int(input())
Xjiku=float(1)
Yjiku=float(0)
ans=int(1)
thita=int(0)
for _ in range(1000000):
    thita += X
    Xjiku += math.cos(math.radians(thita))
    Yjiku += math.sin(math.radians(thita))
    ans += int(1)
    if abs(Xjiku) < float(10**-10) and abs(Yjiku) < float(10**-10):
        break
print(ans)

Solution (Python):
import math

x = int(input())

print(int(360 / math.gcd(360,x)))

Solution (Python):
def gcd(a, b):
  if a < b:
    a, b = b, a
  while b:
    a, b = b, a % b
  return a

def g(a, b):
  return a * b // gcd(a, b)


X = int(input())
print(g(X, 360) // X)

Solution (Python):
def gcd(m,n):
	if n==0:
		return m
	return gcd(n,m%n)
def lcm(a,b):
	return a*b//gcd(a,b)
x=int(input())
l=lcm(360,x)//x
print(l)

Solution (Python):

import math
x = int(input())
lcm = x * 360 / math.gcd(x, 360)
print(int(lcm / x))

Solution (Python):
x=int(input())
y=x;
k=1;
while(x%360):
  x+=y;k+=1;
print(k)

Solution (Python):

import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

X = int(input())

a=lcm(X,360)

print(a//X)

Solution (Python):
X = int(input())
count = 1
while True:
    count += 1
    newX = count * X
    if newX % 360 == 0:
        break

print(int(count))

Solution (Python):
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
        return a

def main():
    X = int( input())
    
    
    for i in range(1, X+1):
        if i*360%X == 0:
            print(i*360//X)
            return
if __name__ == '__main__':
    main()

Solution (Python):
import math

X = int(input())
deg = 360

if deg%X==0:
    ans = deg//X
else:
    ans = ((deg*X)//math.gcd(deg,X))//X

print(ans)

Solution (Python):
X = int(input())

K = 1
dire = X
while True:
  if (dire % 360) == 0:
    break
  K+=1
  dire+=X

  
print(K)

Solution (Python):
X = int(input())
i = 1
while True:
  if (360*i) % X == 0:
    print((360*i) // X)
    exit()
  else:
    i += 1

Solution (Python):

from math import gcd
n = int(input())
print(360//gcd(360, n))

Solution (Python):
a = int(input())
k = 0
t = 1
count = 0
while t == 1 :
     k = k + a
     count = count + 1
     if k % 360 == 0 :
         break

print(count)

Solution (Python):
angle = int(input())

count = 0

while True:
  count += 1
  num = angle * count

  if num % 360 == 0:
    print(count)
    exit()

Solution (Python):
import math
n=int(input())
if 360%n==0:
    print(360//n)
else:
    r=360*n//math.gcd(360,n)
    r//=n
    print(r)

Solution (Python):
from math import gcd
i = int(input())
print((360 * i // gcd(360, i)) // i)

Solution (Python):
X= int(input())
max_test = 100000
for i in range(1,max_test):
  if i * X % 360 == 0:
    break

print(i)

Solution (Python):
X = int(input())


k=0
a=0
while True:

  a = (a+X)%360
  k+=1
  if a==0: break

print(k)

Solution (Python):

import math
import sys


buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(X):
    d = [1, 0]
    c = [0, 0]
    eps = 10**-7
    X /= 360
    X *= 2*math.pi
    for i in range(1, 361):
        c[0] += d[0]
        c[1] += d[1]
        d = [
            d[0]*math.cos(X) - d[1]*math.sin(X),
            d[0]*math.sin(X) + d[1]*math.cos(X)
        ]

        if abs(c[0]) < eps and abs(c[1]) < eps:
            return i
    return i


def main():
    X = read_int()
    print(slv(X))


if __name__ == '__main__':
    main()

Solution (Python):
x = int(input())

sum = 0
times = 0
while sum==0 or sum%360 != 0:
  sum += x
  times += 1

print(times)

Solution (Python):
N = int(input())
for i in range(360):
    if not N * (i + 1) % 360:
        print(i + 1)
        break

Solution (Python):
def gcd(a,b):
    a,b = max(a,b),min(a,b)
    while b:
        a,b =b,a%b
    return a

X=int(input())

if 360%X==0:
    print(360//X)
else:
    g =gcd(360,X)
    print(360//g)

Solution (Python):
import sys
import math
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate 
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache 
from fractions import gcd

def main():
    x = int(input())
    print(360//math.gcd(x, 360))
    
    return 0

if __name__ == "__main__":
    main()

Solution (Python):

import sys, io, os, re
import bisect
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby
from heapq import heapify, heappush, heappop

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]

def ldec(A, d=1): return map(lambda x: x - d, A)

N = n1()

for i in range(1, 10**8):
    if (360 * i) % N == 0: 
        print(int((360*i)/N))
        break

Solution (Python):
X = int(input())

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
def lcm(a, b):
    return a // gcd(a, b) * b

L = lcm(X, 360)


ans = L//X
print(ans)

Solution (Python):
X=int(input())

i=1
while ((360*i) % X) != 0:
    i += 1

ans = int(360*i / X)

print(ans)

Solution (Python):
import math

k = int(input())
g = math.gcd(k, 360)
l = k * 360 // g
print(l // k)

Solution (Python):
x=int(input())
mx=1
for i in range(2,x+1):
    if x%i==0:
        if 360%i==0:
            mx=i
ans=360//mx
print(ans)

Solution (Python):
def compute_lcm(x, y):
   if x > y:
       greater = x
   else:
       greater = y
   while(True):
       if((greater % x == 0) and (greater % y == 0)):
           lcm = greater
           break
       greater += 1
   return lcm
n=int(input())
if(n%360==0):
  print(n//360)
else:
  print(compute_lcm(n,360)//n)

Solution (Python):
X=int(input())
for i in range(1,10000):
  if 360*i%X==0:
    print(360*i//X)
    break

Solution (Python):



def main():
    import sys
    input = sys.stdin.readline

    x = int(input())

    for i in range(1, 10 ** 6):
        if (i * x) % 360 == 0:
            print(i)
            exit()


if __name__ == '__main__':
    main()

Solution (Python):
import math

n = int(input())

lcm = n * 360 // math.gcd(n, 360)
print(lcm // n)

Solution (Python):
X=int(input())

ans=0
tmp=360    

if 360%X==0:
    ans=360//X
else:
    while(1):
        if tmp%X!=0:
            tmp+=360
        else:
            ans=tmp//X
            break
print(ans)

Solution (Python):
X = int(input())

def calc(X):
	n = 1
	while True:
		if 360 * n % X == 0:
			return 360 * n // X
		n += 1

print(calc(X))

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    X = int(input())
    r = X
    ans = 1
    while r % 360 != 0:
        r += X
        ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
X = int(input())
a = 360//X
for i in range(1,1000):
  if (360 * i) % X == 0:
    print(360*i // X)
    exit()

Solution (Python):
x = int(input())
d = 360
while d % x != 0:
	d += 360
print(d // x)

Solution (Python):
a = int(input())
for i in range(1, a*360 + 1):
  if i % 360 == 0 and i % a == 0:
    print(i//a)
    break

Solution (Python):
import sys
input = sys.stdin.readline

def linput(tt=int):
	return list(map(tt,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	
	X = int(input())
	
	res = 0
	R = 360
	
	T = 360
	G = 0
	while T!=G:
		if T>G: G+=X; res+=1
		else: T+=R
	
	print(res)

if __name__ == "__main__":
	main()

Solution (Python):
def gcd(x, y):
  b = max(x, y)
  s = min(x, y)
  r = b % s
  while r != 0:
    b = s
    s = r
    r = b % s
  return s

def lcm(x, y):
  return (x * y) // gcd(x,y)

X = int(input())

t = lcm(360, X)
k = t // X
print(k)

Solution (Python):
X = int(input())
i = 1
flag = 0
while flag == 0:
    if (360*i) % X ==0:
        flag = 1
    else:
        i += 1

print((360*i)//X)

Solution (Python):
import math

def lcm(x, y):
    return (x * y) / math.gcd(x, y)

def main():
    X = int(input())

    total_move = lcm(360, X)
    print(int(total_move // X))

if __name__ == "__main__":
    main()

Solution (Python):
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

x=ii()
l=1

while 1:
    if 360*l % x ==0:
        print((360*l)//x)
        exit()
    l += 1

Solution (Python):
def resolve():
    X = int(input())
    k = 0
    while 1:
        k += 1
        cal = X * k
        if cal % 360 == 0:
            break
    print(k)
    

if __name__ == "__main__":
    resolve()

Solution (Python):
X = int(input())
ls = [2, 2, 2, 3, 3, 5]
a = []
for l in ls:
  if X % l == 0:
    a.append(l)
    X /= l
num = 1
if len(a) != 0:
  for b in a:
    num *= b
print(int(360 / num))

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque


from collections import Counter

from itertools import accumulate,combinations,permutations

from heapq import heapify,heappop,heappush


from functools import lru_cache

from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    

    X= int(input())
    
    
    
    
    pi=math.pi
    vec=[1,0]
    ca=0
    cur=[0,0]
    count=0
    count+=1
    cur[0]+=vec[0]
    cur[1]+=vec[1]
    ca=(ca+X)%360
    vec[0]=math.cos(ca/180*pi)
    vec[1]=math.sin(ca/180*pi)
    
    while cur[0]**2+cur[1]**2>1e-8:
        count+=1
        cur[0]+=vec[0]
        cur[1]+=vec[1]
        ca=(ca+X)%360
        vec[0]=math.cos(ca/180*pi)
        vec[1]=math.sin(ca/180*pi)
        
    print(count)






if __name__ == "__main__":
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    X = int(input())
    ans = INF
    for i in range(1,300):
        if 360*i%X == 0:
            ans = min(ans,360*i//X)
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
import math

X = int(input())
aa = math.gcd(X, 360)
ans = int(360/aa)

print(ans)

Solution (Python):
X = int(input())

count = 0
now = 0
while True:
    count += 1
    now += X
    if now % 360 == 0:
        print(count)
        exit()

Solution (Python):
X=int(input())
K=0
B=0
C=0
for i in range(0,360):
    B=B+X
    C=B%360
    K=K+1
    if C==0:
        print(K)
        break

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys
import cmath

X = int(input())


def solve(X):
    loc = 0 + 1j
    direction = 0 + 1j
    cnt = 1
    while True:
        if abs(loc - 0) < 1e-6:
            break
        direction *= cmath.rect(1.0, X / 360.0 * 2.0 * math.pi)
        
        
        
        loc += direction
        cnt += 1
    return cnt




print(solve(X))

Solution (Python):
x = int(input())
count = 0
direction = 0
while(True):
    direction += x
    count += 1
    if direction % 360 == 0:
        break
print(count)

Solution (Python):
X = int(input())
ls = [2, 2, 2, 3, 3, 5]
a = []
for l in ls:
  if X % l == 0:
    a.append(l)
    X /= l
num = 1
if len(a) != 0:
  for b in a:
    num *= b
print(int(360 / num))

Solution (Python):

X = int(input())

ans = 0
x = 0
while((360-x) % X != 0):
    ans += (360 - x) // X + 1
    x = X - (360-x) % X
ans += (360-x) // X
print(ans)

Solution (Python):
x = int(input())
for i in range(1, 361):
  if 360*i % x == 0:
    print(360*i//x)
    break
else:
  print(360)

Solution (Python):
import math
n=int(input())
if 1 < math.gcd(360,n) < 360:
  print(360//math.gcd(360,n))
else:
  print(360)

Solution (Python):
n=int(input())
t=360
while t%n!=0:
    t=t+360
print(t//n)

Solution (Python):
import math
X = int(input())
x = 1
y = 0
p = math.pi
count = 1
while abs(x) > 1/100000000 or abs(y) > 1/100000000:
    x += math.cos(count*X*p/180)
    y += math.sin(count*X*p/180)
    count += 1
print(count)

Solution (Python):
x=int(input())
for i in range(1,361):
  if 360*i % x == 0:
    print(int(360*i/x))
    exit()

Solution (Python):

x = int(input())
i = 1
while x*i%360 != 0:
    i+= 1

print(i)

Solution (Python):
import math
X = int(input())

lcm = (X * 360) // math.gcd(X, 360)
print(lcm//X)

Solution (Python):
X = int(input())

d = 0
ans = 0
while True:
    d += X
    d %= 360
    ans += 1
    if d == 0:
        break
print(ans)

Solution (Python):
def resolve():
    import math
    X = int(input())
    print(360 // math.gcd(X, 360))


resolve()

Solution (Python):
X = int(input())
for k in range(1,400):
    if (k*X)%360==0:
        break
print(k)

Solution (Python):
import math
x = int(input())

for i in range(1, 10000):
    if x * i % 360 == 0:
        print(i)
        exit()

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))



def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) 
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


MOD = 10**9 + 7
INF = 2**31  

from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  
from math import gcd


X = read_a_int()
now = X
ans = 1
while now % 360 != 0:
    now += X
    ans += 1
print(ans)

Solution (Python):
x = int(input())

kaiten=360
while kaiten%x!=0:
  kaiten+=360
  
print(kaiten//x)

Solution (Python):


import sys
input=sys.stdin.readline

def main():
    X=int(input())
    for i in range(1,180):
        if (360*i)%X==0:
            print(int((360*i)//X))
            exit()
    
    
    
if __name__=="__main__":
    main()

Solution (Python):
i=int(input())
a=0
for j in range(361):
    a=(i+a)%360
    if a==0:
        print(j+1)
        break

Solution (Python):
k = int(input())
i = 1
while i:
    if (i * k) % 360 == 0:
        print(i)
        break
    i += 1

Solution (Python):
import sys
input = sys.stdin.readline
from math import gcd

X=int(input())
LCM=X*360//gcd(360,X)
print(LCM//X)

Solution (Python):
x = int(input())
if 360%x != 0:
	turns = int(360/x)+1
	degrees = turns*x
	while degrees%360 != 0:
		degrees += x
		turns += 1
	print(turns)
else:
	print(int(360/x))

Solution (Python):
M = int(input())
i = 1
while True:
  if(M*i%360==0):
    print(int(i))
    exit()
  else:
    i+=1

Solution (Python):
x=int(input())

i=1
while 1:
    if (360*i)%x==0:
        print((360*i)//x)
        exit()
    i+=1

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    x = int(input())
    if 360 % x == 0:
        res = 360 // x
        print(res)
    else:
        q, r = divmod(360, x)
        print((360 // r) * q)


if __name__ == '__main__':
    resolve()

Solution (Python):
X = int(input())
flag = 0
K = 0
n = 1
ans = 0


def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False


while flag == 0:
    K = (360 * n) / X
    if is_integer_num(K):
        flag = 1
        ans = K
    else:
        n = n + 1

print(int(ans))

Solution (Python):
from math import pi, sin, cos


def read_int():
    return int(input())


deg = read_int()
x = 0.0
y = 0.0
theta = 90.0
rad = 180.0 / pi
cnt = 0
while True:
    cnt += 1
    x += cos(theta / rad)
    y += sin(theta / rad)
    theta += deg
    if x * x + y * y <= 1e-6:
        break

print(cnt)

Solution (Python):
n = int(input())



from math import cos,sin,pi

x,y=[0,0]
rad = 0
for i in range(10000):
    x += cos(pi*rad*n/180)
    y += sin(pi*rad*n/180)
    rad+=1
    if abs(x) < 0.00001 and abs(y) < 0.00001:
        print(i+1)
        exit()

Solution (Python):
n = int(input())
from math import gcd

def lcm(a,b):
    x= a*b // gcd(a,b)
    return x

if 360%(n)==0:
    print(360//n)
else:
    print(lcm(360,n)//n)

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

x = ii()
cnt = 1
tmp = x
while tmp%360 != 0:
    cnt += 1
    tmp += x

print(cnt)

Solution (Python):
from math import gcd
n = int(input())
ans = 360 // gcd(n, 360)
print(ans)

Solution (Python):






X = int(input())





ans = 0
while True:
    ans += 1
    if X*ans % 360 == 0:
        break
print(ans)

Solution (Python):
import sys

import math







input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 1000000007

def move(cur, deg):
    
    x,y = cur
    x += math.cos(math.radians(deg))
    y += math.sin(math.radians(deg))
    
    return (x, y)


def solve():
    
    n = getN()
    eps = 10**-5
    deg = n
    cur = (0, 0)
    ans = 0
    while(True):
        cur = move(cur, deg)
        deg += n
        ans += 1
        cx, cy = cur
        if abs(cx) < eps and abs(cy) < eps:
            print(ans)
            return


def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    
    solve()

Solution (Python):
from math import gcd
def lcm(a,b):
    return a//gcd(a,b)*b
x=int(input())
print(lcm(360,x)//x)

Solution (Python):
X = int(input())
i = 1
while True:
  if (360 * i) % X == 0:
    ans = (360 * i) // X
    break
  else:
    i += 1
print(ans)

Solution (Python):
X = int(input())
ans = 1
d = X
while d%360:
    d += X
    ans += 1
print(ans)

Solution (Python):
if __name__ == "__main__":
    X = int(input().strip())
    i = 1
    while True:
        if 360*i%X == 0:
            break
        else:
            i +=  1
    print(int(360*i/X))

Solution (Python):
import math


X = int(input().strip())

lcm = X * 360 // math.gcd(X, 360)

print(lcm // X)

Solution (Python):
X = int(input())

K = 0
i = 1
while (K+X)%360 != 0:
    K += X
    i += 1
print(i)

Solution (Python):
n = int(input())
a = 0
c = 0
while(True):
  a+=n
  c+=1
  if(a%360 == 0):
    print(c)
    break

Solution (Python):
x = int(input())

print([k for k in range(1, 361) if x*k % 360 == 0][0])

Solution (Python):
def main():
    x = int(input())
    for i in range(2, 361):
        if (x*i)%360 == 0:
            print(i)
            exit(0)
        

if __name__ == "__main__":
    main()

Solution (Python):
import math


def lcm(a, b):
    return a // math.gcd(a, b) * b


X = int(input())
print(lcm(360, X) // X)

Solution (Python):
import math

k, = list(map(int,input().split()))
print(abs(360*k) // math.gcd(360, k) // k)

Solution (Python):
import math
X = int(input())
print(360 // math.gcd(360, X))

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
mod = 10**9 + 7

x = int(input())
import math
lcm = x*360//math.gcd(x, 360)
print(lcm//x)

Solution (Python):
X = int(input())
tmp = X
count = 1
while 360 != tmp:
  tmp += X
  count += 1
  if tmp > 360:
    tmp -= 360
print(count)

Solution (Python):
X = int(input())
c = 1
while True:
    if (360*c)%X == 0:
        a = (360*c)//X
        break
    else:
        c += 1

print(a)

Solution (Python):
X = int(input())
import math

tmp = 360*X//math.gcd(360,X)
ans = tmp//X
print(ans)

Solution (Python):
if __name__ == '__main__':
    from sys import stdin
    
    
    
    
    
    import math
    
    input = stdin.readline

    x = int(input())
    one_round = 360
    print(int(360//math.gcd(one_round, x)))

Solution (Python):
from math import gcd
n = int(input())
print(360*n//gcd(n,360)//n)

Solution (Python):
from math import gcd
n = int(input())

print(360 // gcd(n, 360))

Solution (Python):
import math
x = int(input())
y = math.gcd(x, 360)
print(int(360/y))

Solution (Python):
import sys
readline = sys.stdin.readline
def gcd(a,b):
    while b:
        a, b = b, a%b
    return a

def lcm(a, b):
    return a*b//gcd(a, b)

X = int(readline())
print(lcm(360, X)//X)

Solution (Python):
from fractions import gcd

x = int(input())

print(x * 360 // gcd(x, 360) // x)

Solution (Python):
try:
    from math import gcd
except ImportError:
    from fractions import gcd

x=int(input())

print(360//gcd(x,360))

Solution (Python):
import math


def solve(X):
    def lcm(a, b):
        return a * b // math.gcd(a, b)

    return lcm(360, X) // X


(X,) = [int(x) for x in input().split()]
print(solve(X))

Solution (Python):
def gcd(x, y):
    while y: x, y = y, x % y
    return x

x = int(input())
print(360//gcd(360, x))

Solution (Python):
import math
x=int(input())
print(360//math.gcd(x,360))

Solution (Python):
X=int(input())
i=1
while(True):
	if (360*i)%X==0:
		print((360*i)//X)
		break
	i+=1

Solution (Python):
x = int(input())
y = 360
while y != x:
  if x > y:
    x = x - y
  else:
    y = y - x
print(int(360/x))

Solution (Python):
x =int(input())
for k in range(1,100000):
    if x*k%360==0:
        print(k)
        exit(0)

Solution (Python):
X = int(input())
cnt = X
en = 360
ans = 0
while True:
    if en%cnt==0:
        ans = en//X
        break
    if en < cnt:
        en+=360
    cnt += X
print(ans)

Solution (Python):
x = int(input())
count = x
ans = 1
while count%360!=0:
    count+=x
    ans+=1
print(ans)

Solution (Python):
from math import gcd
x = int(input())
if 360%x == 0:
    print(360//x)
else:
    print(360//(gcd(360,x)))

Solution (Python):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
x = int(input())
t = lcm(x, 360)
print(t // x)

Solution (Python):
import math
X = int(input())
print(360 // math.gcd(X,360))

Solution (Python):


x = int(input())

for i in range(1,1000):
    num = x * i
    if num%360 == 0:
        print(i)
        break

Solution (Python):
import numpy as np

X = int(input())
y = np.lcm(360,X)
print(y//X)

Solution (Python):
def gcd(x,y):
  while y!=0:
    x,y=y,x%y
  return x
print(360//gcd(360,int(input())))

Solution (Python):
import math
X=int(input())
print(int(360*X/math.gcd(360,X)/X))

Solution (Python):
X = int(input())

ans = 1
while (X*ans) % 360 != 0:
  ans += 1
print(ans)

Solution (Python):
X = int(input())
n = 360
c = 0
while True:
    c += n // X
    n %= X
    if n == 0:
        break
    n += 360
print(c)

Solution (Python):
from math import gcd
x = int(input())
print((x*360)//gcd(x,360)//x)

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')
AZ = "abcdefghijklmnopqrstuvwxyz"






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count




N = I()
  
print(360//gcd(N,360))

Solution (Python):
x=int(input())
for i in range(1,1000):
	if 360*i%x==0:
		ans=360*i//x
		break
print(ans)