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
cos=math.cos
sin=math.sin

def solve(x):
    p=math.pi
    z=x/360*p*2
    
    X,Y=0,0
    for i in range(10**5):
        X+=cos(z*i)
        Y+=sin(z*i)
        if X**2+Y**2<10**-6:
            
            return i+1
            break

x=int(input())
print(solve(x))

Solution (Python):
import math
x = int(input())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

lcm = lcm(360, x)
print(int(lcm/x))

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

Solution (Python):
X=int(input())
for i in range(1,10**10):
    K=360*i//X
    if K*X==360*i:
        print(K)
        exit()

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

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

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

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

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

print(count)

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

print(int(lcm/x))

Solution (Python):


def main():
    X = int(input())
    i = 1
    while True:
        if (X * i) % 360 == 0:
            break
        i += 1
    print(i)


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np

input_rad = int(input())
X, Y = 0, 0
Y = 1
t = 1
rad = input_rad

while True:
    radian = rad * np.pi / 180
    x = np.sin(radian)
    y = np.cos(radian)
    X += x
    Y += y
    t += 1
    rad += input_rad
    if abs(X) < 1.0 * np.exp(-5):
        X = 0
    if abs(Y) < 1.0 * np.exp(-5):
        Y = 0
    if X == 0:
        if Y == 0:
            print(t)
            break

Solution (Python):
x = int(raw_input())
p = 0
for i in xrange(361):
    p += x
    if p % 360 == 0:
        print i + 1
        break

Solution (Python):
n = int(input())
import numpy as np
x=0
y=0
rad=0
k=1
while(1):
  y+=np.cos(rad*np.pi/180)
  x+=np.sin(rad*np.pi/180)
  if x<0.0001 and y<0.0001:
    print(k)
    break
  else:
    k+=1
    rad+=n

Solution (Python):


LI = lambda: list(map(int, input().split()))


X = int(input())


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


def main():
    g = gcd(X, 360)
    v = X // g
    ans = 360 * v // X
    print(ans)


if __name__ == "__main__":
    main()

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

print(i)

Solution (Python):
import math
def lcm(x, y):
    '''
    最小公倍数の計算
    '''
    return (x * y) // math.gcd(x, y)

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

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

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

x = a
i = 1

while x % 360 != 0:
    x += a
    i += 1

print(i)

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

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

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

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

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

k = 0
sum = 0

while True:
    sum += x
    k += 1
    if sum % 360 == 0:
        break

print(k)

Solution (Python):
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

X = int(input())


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


l = lcm(360, X)

print(l // X)

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

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

Solution (Python):
n = int(input())
a = n
i = 1
while a % 360 != 0:
    a += n
    i += 1
print(i)

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

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

Solution (Python):
n=int(input())
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
g=gcd(n,360)
print(int(360/g))

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

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

Solution (Python):
import math

x = int(input())
a = math.gcd(360,x)
b = int(x/a)
c= int(360/a)
d = c*b
print(c)

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

for i in range(3,361):
    xk = x*i
    if xk%360 == 0:
        print(i)
        exit()

Solution (Python):
x = int(input())
k = 360 / x
if k.is_integer():
  print(int(k))
else:
  for idx in range(2, x+1):
    tmp = k * idx
    if tmp.is_integer():
      print(int(tmp))
      break

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

Solution (Python):
import math

angle = int(input())
c = 1
x = 0
y = 1

while [round(x,2),round(y,2)] != [0,0]:
  angle_u= 180-angle*c
  y -= math.cos(math.radians(angle_u))
  x -= math.sin(math.radians(angle_u))
  c += 1
else:
  print(c)

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


def my_gcd(a, b):
    cum = a * b
    if a > b:
        a, b = b, a
    while a != 0:
        a, b = b % a, a
    
    return b


print(360 // my_gcd(x, 360))

Solution (Python):

x = int(input())
c = x

if 360%x ==0:
    print(int(360/x))
else:
    ct = 0
    while 360%x != 0 and x %360!=0:
        ct += 1
        x += c
    
    print(ct+1)

Solution (Python):

"""AtCoder Grand Contest 046: A - Takahashikun, The Strider
https://atcoder.jp/contests/agc046/tasks/agc046_a
"""


def calc(x):
    mod = 360 % x
    ans = 360 // x
    if mod == 0:
        return ans
    angle = 360 - mod
    while True:
        angle += x
        ans += 1
        if angle % 360 == 0:
            return ans


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


if __name__ == '__main__':
    main()

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

while True:
  y=i*360/x
  i+=1
  if y%1==0:
    break
print(int(y))

Solution (Python):

"""AtCoder Grand Contest 046: A - Takahashikun, The Strider
https://atcoder.jp/contests/agc046/tasks/agc046_a
"""


def calc(x):
    mod = 360 % x
    ans = 360 // x
    if mod == 0:
        return ans
    angle = 360 - mod
    while True:
    
        
        angle += x
        ans += 1
        if angle % 360 == 0:
            return ans
    
    
    
    
    
    
    
    
    
    
    


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


if __name__ == '__main__':
    main()

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

Solution (Python):
import math

x = int(input())

y = 180-x

a = 360//math.gcd(360,x)

print(a)

Solution (Python):
from math import gcd

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

Solution (Python):
import math

X= int(input())
g = math.gcd(360,X)

if 360 % g != 0:
  print(360)
else:
  print(int(360/g))

Solution (Python):
import math
X = int(input())
Y = X
x = 1
y = 0
K = 1
while x != 0 or y != 0:
    x = round(x + math.cos(math.radians(X)),6)
    y = round(y + math.sin(math.radians(X)),6)
    X = X + Y 
    K += 1
print(K)

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

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

count = 1
total_digree = X
while True:
    if total_digree % 360 == 0:
        break
    count += 1
    total_digree += X

print(count)

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

Solution (Python):
def main():
    import math
    x = int(input())
    a, b = 0, 0
    t = 0
    c = 0
    while True:
        c += 1
        t += x
        t %= 360
        a += math.cos(math.radians(t))
        b += math.sin(math.radians(t))
        if abs(a) < 10 ** -13 and abs(b) < 10 ** -13:
            print(c)
            break

if __name__ == '__main__':
    main()

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

print(360*b//x)

Solution (Python):

x = int(input())
k = 0

def gcd(a,b):
    if b == 0:
        return a

    return gcd(b, a%b)

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

saishoukoubai = lcm(360, x)
k = saishoukoubai / x

k = int(k)
print(k)

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

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

Solution (Python):
from fractions import Fraction
X = int(input())






    
print(Fraction(360, X).numerator)

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

Solution (Python):
import math
from fractions import Fraction
X = int(input())
n = 360 / X
m = Fraction(360,X)
s = m.denominator
a,b = math.modf(n)
if a == 0.0:
    print(int(n))
elif a != 0.0:
    ans = m * s
    print(int(ans))

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

r = 0
cnt = 0
while True:
    r += x
    cnt += 1
    if r == 360:
        break
    if r > 360:
        r -= 360

print(cnt)

Solution (Python):
import math
import time

X = int(input())
K = 0
a = X
E = 0.1 ** 5

now = [0.0, 0.0]
while True:
    if now[0] <= E and now[0] >= -E and now[1] >= -E and now[1] <= E and K:
        print(K)
        break

    now[0] += math.cos(math.radians(a))
    now[1] += math.sin(math.radians(a)) 

    a += X
    K += 1

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

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

n = int(input())

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

Solution (Python):
import math
M = 360
X = list(map(int, input().split()))[0]
Y = math.gcd(M, X)

result = M // Y
print(result)

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

ans=1
while True:
    q=360//x
    r=360%x
    ans*=q
    if r==0:
        break
    x=r
print(ans)

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

eps = 10**-5

def sim(rot):
    x, y = 0, 0
    nx, ny = 0, 1
    cnt = 0
    while True:
        x += nx
        y += ny
        
        
            
        cnt += 1
        if -eps <= x <= eps and -eps <= y <= eps:
            break
        nx, ny = nx * cos(radians(rot)) -  ny * sin(radians(rot)), ny * cos(radians(rot)) + nx * sin(radians(rot))
    return cnt




n = int(input())
print(sim(n))

Solution (Python):
import math
x = int(input())
tol = 1e-6
ans = 1
cur = [0,1]
unit = x/180*math.pi
while cur[0]**2 + cur[1]**2 > tol:
    cur[0] += math.sin(ans*unit)
    cur[1] += math.cos(ans*unit)
    ans += 1
print(ans)

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

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


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

Solution (Python):

from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

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

Solution (Python):
import math

turn_angle = int(input())

current_angle = 90
position_dict = {'x': 0, 'y': 0}
move_one = {'x':0, 'y': 1}
num_actions = 1


def change_angle(turn_angle, current_angle):
    current_angle = current_angle + turn_angle
    if current_angle > 360:
        current_angle = current_angle - 360
    return current_angle

def resolve_direction(current_angle):
    radian_angle = (current_angle*math.pi)/180
    move_dict = {'x':round(math.cos(radian_angle), 3), 'y' : round(math.sin(radian_angle), 3)}
    return move_dict

def move_skater(position_dict, move_dict):
    for key, value in position_dict.items():
        position_dict[key] = round((value + move_dict.get(key, 0)), 3)
    return position_dict

position_dict = move_skater(position_dict, move_one)
current_angle = change_angle(turn_angle, current_angle)


origin_dict = {'x': 0.0, 'y': 0.0}

while position_dict != origin_dict:
    move_dict = resolve_direction(current_angle)
    position_dict= move_skater(position_dict, move_dict)
    current_angle = change_angle(turn_angle, current_angle)
    num_actions = num_actions + 1

print(num_actions)

Solution (Python):
def do():
    x=int(input())
    k=360%x
    j=360//x
    v=k
    if k==0:
        return j
    while 360%k!=0:
        k=360%k
        v+=k
    v1=360//v
    return j*v1
print(do())

Solution (Python):
from math import gcd

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

Solution (Python):

r=int(input())
d=360
while d%r!=0:
    d+=360
print(d//r)

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

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

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

Solution (Python):
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    return gcd(y,x%y)
def lcm(x,y):
    return x*y//gcd(x,y)

def main():
    x=int(input())
    l=lcm(360,x)
    print(l//x)
    
if __name__=='__main__':
    main()

Solution (Python):

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

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

Solution (Python):
def main():
    x = int(input())
    if False:
        print((360 // x) if 360%x == 0 else (360 // x)+1)
    else:
        k = 1
        temp = x
        while temp % 360 != 0:
            k += 1
            temp += x
        print(k)


    temp = 360 // x

if __name__ == '__main__':
    main()

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

Solution (Python):
import math
def main():
    N = int(input())
    K = 0
    X = 0
    Y = 0
    R = 90

    while True:
        R = (N+R)%360
        K+=1
        X += math.cos(math.radians(R))
        Y += math.sin(math.radians(R))
        if abs(X)<0.0005 and abs(Y)<0.0005:
            print(K)
            break

if __name__ == '__main__':
    main()

Solution (Python):
import math


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

Solution (Python):
import numpy as np

x = int(input())

d = 180 - x
ans = 360 // np.gcd(360, 180-d)
print(ans)

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

Solution (Python):
n=int(input())
if(360%n==0):
  print(360//n)
else:
  i=1;
  while (n*i)%360!=0:
    i+=1
  print(i)

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

Solution (Python):
k = int(input())
ct = 1
goal = k
while k:
  ct += 1
  k = (k + goal) % 360
print(ct)

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

Solution (Python):
a=int(input())
b=a
c=1
while b!=0:
    b=b+a
    b=b%360
    c=c+1
print(c)

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

Solution (Python):
k = (int)(input())
if k % 360 == 0:
  print(1)
elif k % 180 == 0:
  print(2)
elif k % 120 == 0:
  print(3)
elif k % 90 == 0:
  print(4)
elif k % 72 == 0:
  print(5)
elif k % 60 == 0:
  print(6)
elif k % 45 == 0:
  print(8)
elif k % 40 == 0:
  print(9)
elif k % 36 == 0:
  print(10)
elif k % 30 == 0:
  print(12)
elif k % 24 == 0:
  print(15)
elif k % 20 == 0:
  print(18)
elif k % 18 == 0:
  print(20)
elif k % 15 == 0:
  print(24)
elif k % 12 == 0:
  print(30)
elif k % 10 == 0:
  print(36)
elif k % 9 == 0:
  print(40)
elif k % 8 == 0:
  print(45)
elif k % 6 == 0:
  print(60)
elif k % 5 == 0:
  print(72)
elif k % 4 == 0:
  print(90)
elif k % 3 == 0:
  print(120)
elif k % 2 == 0:
  print(180)
else:
  print(360)

Solution (Python):
x=int(input())
c=0
n=0
if 360%x ==0:
    print(int(360/x))
else:
    while not(n==0 and c>0):
        n=(n+x%360)%360
        c+=1
    print(c)

Solution (Python):
X = int(input())
m  = 1
while(360*m%X!=0):
    m+=1
print(360*m//X)

Solution (Python):

def main():
    X = int(input())
    ans = 0
    x = 360
    while x != 0:
        x = x - X
        ans += 1
        if (x < 0):
            x += 360
    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
x = int(input())
total = 0
ans = 0

i = 0
while i == 0:
    total = total + x
    ans = ans + 1
    if total % 360 == 0:
        print(ans)
        break

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

Solution (Python):
a = int(input())
x = a
k = 1
while a != 360:
    a = a + x
    if a > 360 :
        a = a - 360
    k = k + 1
print(k)

Solution (Python):
def gcda(a,b):
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    return gcda(r, b)

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

X=int(input())
shukai=360
while True:
    if shukai%X==0:
        print(shukai//X)
        exit()
    else:
        shukai=lcm(shukai,X)

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

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

n = 1
while True:
  if (n * x) % 360 == 0:
    break
  else:
    n += 1

print(n)

Solution (Python):
import math
x=int(input())
ct=0
for i in range(1000):
  ct+=x
  if ct%360==0:
    print(i+1)
    exit()

Solution (Python):
import sys
x = int(input())
y = 0
m = 1
if 360 % x == 0:
    m = int(360 / x)
else:
    for i in range(1, 1000):
        y = x * i
        if y > 360:
            if y % 360 == 0:
                m = i
                break
                
print(m)

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

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

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

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

Solution (Python):
x=int(input())
a=1
b=x

while True:
  if (float(b/360)).is_integer(): print(a);break
  else:b += x;a+=1

Solution (Python):
X = int(input())
num = []
kekka = []
N = 2
if 360 % X == 0:
    print(int(360/X))
else:
    while N != X:
        if X / N != 1:
            if X % N == 0:
                num.append(N)
                X /= N
            else:
                N += 1
    num.append(N)
    Z = 1
    for i in range(len(num)):
        Z *= num[i]
    en = [2,2,2,3,3,5]
    for i in range(len(num)):
        if num[i] in en:
            kekka.append(num[i])
            en.remove(num[i])
        else:
            kekka.append(num[i])
    for i in range(len(en)):
        kekka.append(en[i])
    Y = 1
    for i in range(len(kekka)):
        Y *= kekka[i]
    print(int(Y / Z))

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

angle = 0
count = 0
while True:
    angle += X
    count += 1
    if angle % 360 == 0:
        break

print(count)

Solution (Python):
import math
x = int(input())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
if x == 1:
  print(int(360 / x))
elif x == 45:
  print(int(360 / x))
elif x == 90:
  print(int(360 / x))
else:
  z = lcm(x, 360)
  print(int(z / x))

Solution (Python):
from sys import stdin,stdout



Pi = lambda x: stdout.write(str(x) + '\n')
Ps = lambda x: stdout.write(str(x))
S = lambda x: x*(x+1) // 2
I = lambda x: 1+(2*x)
R = lambda:stdin.readline()
Ri = lambda x:map(int,x.split())
Rs = lambda x:map(str,x.split())
Rf = lambda x:map(float,x.split())
char = lambda x,y:ord(x) - ord(y) 
gcd = lambda a,b: a if b==0 else gcd(b, a%b) 
lcm = lambda a,b: a * b // gcd(a, b)

distance = lambda a,b,c,d: ((a-c)**2) + ((b-d)**2)

MaxN = int(1e6) + 10
mod = int(1e9) + 7




 
def main():             
    for x in stdin:     
        if x=='\n':continue    
        n = int(x)
        ans = 1
        while (ans*n)%360!=0:
        	ans += 1
        Pi(ans)

if __name__ == '__main__':
       	main()

Solution (Python):
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))



X = I()

count = 1
eps = 10**(-6)
now = [0,1]
while True:
    count += 1
    now[0] -= math.sin(math.radians((count-1)*X))
    now[1] += math.cos(math.radians((count-1)*X))
    if abs(now[0]) < eps and abs(now[1]) < eps:
        print(count)
        exit()

Solution (Python):


a = int(input())

m = a
c = 1
while m % 360 != 0:
	m+=a
	c+=1
print(c)

Solution (Python):
x = int(input())
tmp = 0
ans = 0

while True:
    tmp += x
    ans += 1
    if tmp % 360 == 0:
        break

print(ans)

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

Solution (Python):
from math import sin, cos, pi
import cmath
x = int(input())
i = 0
now = 0+0j

while True:
    now += cmath.rect(1,2*pi*x*i/360)
    i += 1
    if abs(now-(0+0j)) < 10**(-8):
        break
print(i)

Solution (Python):
import sys

def _i(): return int(sys.stdin.readline().strip())


def gcd(x, y):
    if x < y:
        x, y = y, x
    if x % y == 0:
        return y
    else:
        return gcd(y, x % y)


def main():
    a = _i()
    return 360 // gcd(360, a)


if __name__ == "__main__":
    print(main())

Solution (Python):
a = int(input())
res = 0
remainer = 0
while True:
    res += (360+remainer)//a
    remainer = (360+remainer)%a
    if remainer==0:break
print(res)

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

Solution (Python):
import math


n = int(input())
x = 0
y = 1
deg = 90 - n
cnt = 1

while 1 == 1:
    x += math.cos(math.radians(deg))
    y += math.sin(math.radians(deg))
    deg -= n
    cnt += 1
    if x > -10**(-5) and x < 10**(-5) and y > -10**(-5) and y < 10**(-5):
        break
print(cnt)

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

K = 0
rad = 360
while rad != 0:
    rad -= X
    K += 1
    if rad < 0:
        rad += 360
print(K)

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

Solution (Python):
def solve(X):
    cnt = 1
    while True:
        if (X * cnt) % 360 == 0:
            return cnt
        else:
            cnt += 1

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

if __name__ == "__main__":
    main()

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

for i in range(1,x_max+1):
    if((360 * i) % x == 0):
        tmp = (360 * i) / x
        print(int(tmp))
        break

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

for j in range(1,1000):
    if X*j%360==0:
        print(j)
        break

Solution (Python):
X = int(input())
theta, k = 0, 0
while theta % 360 != 0 or theta == 0:
    theta += X
    k += 1
print(k)

Solution (Python):
def lcm(a, b):
    max_num = max(a, b)
    while True:
        if max_num % a == 0 and max_num % b == 0:
            break
        max_num += 1
    return max_num


n = int(input())
l = lcm(n, 360)
print(l//n)

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

Solution (Python):
import numpy as np
import math

rotate = int(input())

x = 0
y = 1
heading = 90

count = 1

while True:
    heading += rotate
    x += np.cos(np.deg2rad(heading))
    y += np.sin(np.deg2rad(heading))
    count += 1
    
    
    

    if math.isclose(x, 0.0,abs_tol=0.000001) and math.isclose(y, 0.0,abs_tol=0.0000001):
        break

print(count)

Solution (Python):
x = int(input())
r = 360
count = 0
while r != 0:
  r = r - x
  if r < 0:
    r += 360
  count += 1
print(count)

Solution (Python):


import math





X = int(input())







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



print(int(lcm / X))

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

ans = 360
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

ans = 360 // gcd(X, 360)
print(ans)

Solution (Python):
import argparse
import collections
import logging.config
import sys
import csv
import numpy as np

def tstr(n):
  total = n
  cnt = 1
  while total%360 != 0:

    cnt += 1
    total += n 
  return (cnt)


def main():
  N = int(input())
  print (tstr(N))

if __name__ == '__main__':
    main()

Solution (Python):
if __name__ == "__main__":
    x = int(input())

    count = 0
    theta = 0
    while True:
        count += 1
        theta += x
        if theta%360 == 0:
            break

    print(count)

Solution (Python):



M = 1000000
P = 180


def compute(x):
    for n in range(1, M):
        k, mo = divmod(2 * n * P, x)
        if mo == 0:
            return k
    raise Exception("Not Found")    


def main():
    x = int(input())
    k = compute(x)
    print(k)


if __name__ == '__main__':
    main()

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

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

Solution (Python):
x=int(input())
n=1
tgt=1
Ans=0
while tgt>0:
    tgt=(360*n)%x
    Ans=(360*n)//x
    n+=1
print(Ans)

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

from fractions import gcd
x = n * 360 // gcd(n, 360) 

print(x//n)

Solution (Python):
from fractions import Fraction

x = input()

y = Fraction("360/"+x)

print(y.numerator)

Solution (Python):
import math

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

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
from math import gcd,ceil

def lcm(a,b):return a*b//gcd(a,b)
x=int(input().rstrip())
print(360//x if 360%x==0 else (lcm(360,x)//x))

Solution (Python):
import math
from collections import Counter, defaultdict
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())

import math
deg = rri()
d = (-1,0)
cur = (-1, 0)
ans = 1
deg = 2*math.pi*deg/360

while (cur[0]**2+cur[1]**2)>1e-5:
    x, y = d
    new_x, new_y = math.cos(deg)*x-math.sin(deg)*y, math.sin(deg)*x+math.cos(deg)*y
    d = (new_x, new_y)
    cur = (cur[0]+new_x, cur[1]+new_y)
    ans+=1
print(ans)

Solution (Python):
import sys
input=sys.stdin.readline
x=int(input())
import math
y=math.gcd(360,x)
z=x*360//y
ans=z//x
print(ans)

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

for n in range(1,361):
    if 360*n%X==0:
        print(int(360*n/X))
        exit()

Solution (Python):
X = int( input() )
K = 1
angle = X
while angle%360>0:
  angle += X
  K += 1
print(K)

Solution (Python):
import collections

def main():
    n = int(input())
    dd=collections.defaultdict(int)
    for i in range(1,n+1):
        dd[i*360]+=1
    for i in range(360*(n+1)):
        if(dd[n*i]>0):
            print(i)
            exit()


if __name__ == '__main__':
    main()

Solution (Python):
def factor(n):
  l=[]
  while n%2==0:
    n=n//2
    l.append(2)
  for i in range(3,int(n**0.5)+1,2):
    while n%i==0:
      n=n//i
      l.append(i)
  if n>2:
    l.append(n)
  return l

n=int(input())
if 360%n==0:
  print(360//n)
else:
  ll=factor(n)
  mul=1
  
  use=360
  for i in range(len(ll)):
    if use%ll[i]==0:
      use=use//ll[i]
    else:
      mul*=ll[i]
  print((360*mul)//n)

Solution (Python):
import math
degree =int(input())
degree = math.radians(degree)
count = [1]
x, y = 0, 0
for i in count:
    xi, yi = math.cos(i * degree), math.sin(i * degree)
    x += xi
    y += yi
    if -0.000001 <= x<= 0.000001 and -0.000001 <= y<= 0.000001:
        print(i)
    else:
        count.append(i+1)

Solution (Python):
import math

ang = int(input())
rad = ang/360*(2*math.pi)

k = 1
x = 1.0
y = 0.0
current = 0
while round(x,3) != 0.0 or round(y,3) != 0.0:

    current += rad
    x += math.cos(current)
    y += math.sin(current)

    k+=1

print(k)

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

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

for k in range(1, 361):
    if (X * k) % 360 == 0:
        print(k)
        break

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

Solution (Python):
import math

def move(i,j,angle):
    rad = 2*(angle/360)*math.pi
    si = i + math.cos(math.radians(angle))
    sj = j + math.sin(math.radians(angle))
    return [round(si,5),round(sj,5)]

x = int(input())

i,j = 0,0
angle = 90
ans = 0

while 1:
    
    i,j = move(i,j,angle)
    
    angle += x
    ans += 1
    if(i == 0 and j == 0):
        break

print(ans)

Solution (Python):
import numpy as np

X = float(input())
posx = 0.0
posy = 0.0
K = 0
theta = 0.0
while True:
    posx += np.cos(theta)
    posy += np.sin(theta)
    theta += X / 180 * np.pi
    K += 1
    if np.abs(posx) < 0.000000001 and np.abs(posy) < 0.000000001:
        break
print(K)

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

theta, k = 0, 0
while theta != 360:
    theta += X
    k += 1
    if theta > 360:
        theta -= 360
print(k)

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

Solution (Python):
from math import ceil
x = int(input())
n = 360
while(n%x):
	n+=360

print(n//x)

Solution (Python):
from math import gcd
def resolver(X):
    i = 1
    while True:
        if (360 * i) % X == 0:
            return (360 * i) // X
        i += 1



def main():
    X = int(input())
    ans = resolver(X)
    print(ans)


if __name__ == '__main__':
    main()

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

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

Solution (Python):
from math import gcd

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