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



Sample input:
90


Sample output:
4

Submission status: Accepted

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  c=0
  x=0
  while True:
    c+=1
    x+=n
    x%=360

    if x==0:
      return c

# main()
print(main())

Submission status: Accepted

Solution code:
def gcd(a,b):
  if b == 0:return a
  return gcd(b,a%b)
 
a = int(input())
print(360//gcd(360,a))

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
p = int(input())
index = 1
while True:
    if p* index % 360 == 0:
        print(index)
        break
    index += 1

Submission status: Accepted

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

from math import gcd        #for python3.8

def lcm(a,b):
    G = gcd(a, b) #最大公約数
    L = (a//G)*b #最小公倍数
    return L

def main():
    X = int(input())
    print(lcm(X,360)//X)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

X = int(input())

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

Submission status: Accepted

Solution code:
from math import gcd

# X * K = 360 * n

lcm = lambda x, y: (x * y) // gcd(x, y)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    from math import gcd

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
from math import sin, cos, radians
it = lambda: list(map(int, input().strip().split()))
INF = float('inf')

def solve():
    X = int(input())
    ans = 0
    
    degree = 90
    
    x = y = 0
    while True:
        ans += 1
        x += cos(radians(degree))
        y += sin(radians(degree))
        degree = (degree + X) % 360
        if abs(x) < 1e-7 and abs(y) < 1e-7:
            return ans

if __name__ == '__main__':
    print(solve())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

x = int(input())


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


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

Submission status: Accepted

Solution code:
import numpy;x=int(input());print(numpy.lcm(360,x)//x)

Submission status: Accepted

Solution code:
import numpy
x=int(input());print(numpy.lcm(360,x)//x)

Submission status: Accepted

Solution code:
x = int(input())
k = 1
d = x
while d % 360 != 0:
  k += 1
  d += x
print(k)

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
X=int(input())
if 360 % X == 0:
    print(360//X)
else:
    k=1
    while True:
        if (X*k)%360==0:
            break
        k+=1
    print(k)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
x=int(input())
for m in range(1,180):
    if 360*m%x==0:
        print(360*m//x)
        exit(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    X = int(input())
    print(X * 360 // math.gcd(360, X) // X)    


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
res = 1
while True:
    if (res * n) % 360 == 0:
        break
    res += 1
print(res)

Submission status: Accepted

Solution code:
x = int(input())
print([360*n//x for n in range(1, 500) if 360 * n % x == 0][0])

Submission status: Accepted

Solution code:
import math


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


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

Solution code:
X=int(input())

import math
P=[0,1]
X0=90
for i in range(1,361):
    X0+=X
    P[0]+=math.cos(X0/180*math.pi)
    P[1]+=math.sin(X0/180*math.pi)
    if abs(P[0])<1e-10 and abs(1-P[1])<1e-10:
        print(i)
        break

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(X: int):
    target = 360
    count = 0
    while True:
        mod = target % X
        div = target // X
        count += div
        if mod == 0:
            break
        else:
            target = 360 + mod

    print(count)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
n = int(input())
print(360 // math.gcd(360, n))

Submission status: Accepted

Solution code:
from math import gcd
X = int(input())

def lcm(n, m):
    return n * m // gcd(n, m)

print(lcm(X, 360) // X)

Submission status: Accepted

Solution code:
x = int(input())
for i in range(1000):
    if x * (i+1) % 360 == 0:
        print(i+1)
        exit()

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

X = i()
print(lcm(X,360)//X)

Submission status: Accepted

Solution code:
import sys
x=int(input())

for j in range(1,361):
    for k in range(1,361):
        if 360*k==x*j:
            print(j)
            sys.exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
if 360 % X == 0:
  ans = int(360 / X)
else:
  import math
  kaku = (360 * X) / math.gcd(360, X)
  ans = int(kaku / X)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

x = input()
x = int(x)

lcd=(360*x)//math.gcd(360,x)

print(lcd//x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
cnt = 0
pos = 360
muki = int(input())
while pos != 0:
    pos += muki
    pos %= 360
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
x = int(input())

k = 1
while True:
    if x*k % 360 == 0:
        print(k)
        exit()
    k += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

x = int(input())

z = (x * 360) // math.gcd(x, 360)

print(z//x)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from math import gcd
def resolve():
    x = int(input())
    g = gcd(x, 360)
    print(360 // g)
resolve()

Submission status: Accepted

Solution code:
def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)
ans = 360 // (gcd(360, int(input())))
print(ans)

Submission status: Accepted

Solution code:
def gcd(a,b):
    # assume a,b are +ve integers.
    if a>b:
        a,b = b,a
    if b%a==0:
        return a
    
    return gcd(a,b%a)
print(360//(gcd(360,int(input()))))

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
X = int(input())

n = 1
nX = [X]
k = 360
mk = [360]

while True:
    if mk.count(nX[-1]) == 1:
        print(n)
        break
    n += 1
    mk.append(n * k)
    nX.append(n * X)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Template 1.0
import sys, re
from decimal import *
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, floor, trunc, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


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


'''

k = (360*n)/x

if x==7
    n is 7
    
    


'''

Submission status: Accepted

Solution code:
X = int(input())

for i in range(1,1000000000):
    if ( X * i ) % 360 == 0:
        print(i)
        quit()

Submission status: Accepted

Solution code:
X = int(input())

k = 1
while True:
    if (X * k) % 360 == 0:
        print(k)
        exit()
    k += 1

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

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

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    X = Scanner.int()
    for k in range(1, 1000):
        if k * X % 360 == 0:
            print(k)
            return


def main():
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

Solution code:
from math import gcd

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

Submission status: Accepted

Solution code:
X=int(input())
ans=1
while X*ans%360>0:
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
for n in range(3, 361):
   if n * x % 360 == 0:
      print(n)
      exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
do = 360
while True:
    if do % x == 0:
        print(do//x)
        break
    else:
        do += 360

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys
input = sys.stdin.readline
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

from fractions import gcd
x = inp()
ans = 360//gcd(360,x)
print(ans)

Submission status: Accepted

Solution code:
import math
 
k = 1
x = float(input())
while  x*k%360 != 0:
  k += 1	
print(k)

Submission status: Accepted

Solution code:
X = int(input())
 
ans = 0
while(1):
  ans += 1
  if (X * ans) % 360 == 0:
    print(ans)
    break

Submission status: Accepted

Solution code:
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

class Geometry:
    """ 幾何学計算用クラス """

    def __init__(self, EPS):
        self.EPS = EPS

    def add(self, a, b):
        x1, y1 = a
        x2, y2 = b
        return (x1+x2, y1+y2)

    def sub(self, a, b):
        x1, y1 = a
        x2, y2 = b
        return (x1-x2, y1-y2)

    def mul(self, a, b):
        x1, y1 = a
        if not isinstance(b, tuple):
            return (x1*b, y1*b)
        x2, y2 = b 
        return (x1*x2, y1*y2)

    def div(self, a, b):
        x1, y1 = a
        if not isinstance(b, tuple):
            return (x1/b, y1/b)
        x2, y2 = b
        return (x1/x2, y1/y2)

    def abs(self, a):
        from math import hypot
        x1, y1 = a
        return hypot(x1, y1)

    def norm(self, a):
        x, y = a
        return x**2 + y**2

    def dot(self, a, b):
        x1, y1 = a
        x2, y2 = b
        return x1*x2 + y1*y2

    def cross(self, a, b):
        x1, y1 = a
        x2, y2 = b
        return x1*y2 - y1*x2

    def project(self, seg, p):
        """ 線分segに対する点pの射影 """

        p1, p2 = seg
        base = self.sub(p2, p1)
        r = self.dot(self.sub(p, p1), base) / self.norm(base)
        return self.add(p1, self.mul(base, r))

    def reflect(self, seg, p):
        """ 線分segを対称軸とした点pの線対称の点 """

        return self.add(p, self.mul(self.sub(self.project(seg, p), p), 2))

    def ccw(self, p0, p1, p2):
        """ 線分p0,p1から線分p0,p2への回転方向 """

        a = self.sub(p1, p0)
        b = self.sub(p2, p0)
        # 反時計回り
        if self.cross(a, b) > self.EPS: return 1
        # 時計回り
        if self.cross(a, b) < -self.EPS: return -1
        # 直線上(p2 => p0 => p1)
        if self.dot(a, b) < -self.EPS: return 2
        # 直線上(p0 => p1 => p2)
        if self.norm(a) < self.norm(b): return -2
        # 直線上(p0 => p2 => p1)
        return 0

    def intersect(self, seg1, seg2):
        """ 線分seg1と線分seg2の交差判定 """

        p1, p2 = seg1
        p3, p4 = seg2
        return (
            self.ccw(p1, p2, p3) * self.ccw(p1, p2, p4) <= 0
            and self.ccw(p3, p4, p1) * self.ccw(p3, p4, p2) <= 0
        )

    def get_distance_PP(self, p1, p2):
        from math import hypot

        x1, y1 = p1
        x2, y2 = p2
        return hypot(x1-x2, y1-y2)

    def get_distance_LP(self, line, p):
        """ 直線lineと点pの距離 """

        p1, p2 = line
        return abs(self.cross(self.sub(p2, p1), self.sub(p, p1)) / self.abs(self.sub(p2, p1)))

    def get_distance_SP(self, seg, p):
        """ 線分segと点pの距離 """

        p1, p2 = seg
        if self.dot(self.sub(p2, p1), self.sub(p, p1)) < 0: return self.abs(self.sub(p, p1))
        if self.dot(self.sub(p1, p2), self.sub(p, p2)) < 0: return self.abs(self.sub(p, p2))
        return self.get_distance_LP(seg, p)

    def get_distance_SS(self, seg1, seg2):
        """ 線分seg1と線分seg2の距離 """

        p1, p2 = seg1
        p3, p4 = seg2
        if self.intersect(seg1, seg2): return 0
        return min(
            self.get_distance_SP(seg1, p3), self.get_distance_SP(seg1, p4),
            self.get_distance_SP(seg2, p1), self.get_distance_SP(seg2, p2),
        )

    def get_cross_pointSS(self, seg1, seg2):
        """ 線分seg1と線分seg2の交点 """

        p1, p2 = seg1
        p3, p4 = seg2
        if not self.intersect(seg1, seg2): return (INF, INF)
        if p1 == p2: return p2
        if p3 == p4: return p3
        base = self.sub(p4, p3)
        dist1 = abs(self.cross(base, self.sub(p1, p3)))
        dist2 = abs(self.cross(base, self.sub(p2, p3)))
        t = dist1 / (dist1+dist2)
        return self.add(p1, self.mul(self.sub(p2, p1), t))

    def intersectCL(self, c, line):
        """ 円cと直線lineの交差判定 """

        x, y, r = c
        return self.get_distance_SP(line, (x, y)) <= r

    def get_cross_pointCL(self, c, line):
        """ 円cと直線lineの交点 """
        from math import sqrt

        if not self.intersectCL(c, line): return -1
        x, y, r = c
        p1, p2 = line
        pr = self.project(line, (x, y))
        e = self.div(self.sub(p2, p1), self.abs(self.sub(p2, p1)))
        base = sqrt(r*r - self.norm(self.sub(pr, (x, y))))
        return [self.add(pr, self.mul(e, base)), self.sub(pr, self.mul(e, base))]

    def arg(self, p):
        from math import atan2
        x, y = p
        return atan2(y, x)

    def polar(self, a, r):
        from math import sin, cos
        return (cos(r)*a, sin(r)*a)

    def intersectCC(self, c1, c2):
        """ 円c1と円c2の交差判定 """
        from math import hypot

        x1, y1, r1 = c1
        x2, y2, r2 = c2
        return hypot(x1-x2, y1-y2) <= r1 + r2
    
    def get_cross_pointCC(self, c1, c2):
        """ 円c1と円c2の交点 """
        from math import acos

        if not self.intersectCC(c1, c2): return -1
        x1, y1, r1 = c1
        x2, y2, r2 = c2
        try:
            d = self.abs(self.sub((x1, y1), (x2, y2)))
            a = acos((r1*r1+d*d-r2*r2) / (2*r1*d))
            t = self.arg(self.sub((x2, y2), (x1, y1)))
            return [self.add((x1, y1), self.polar(r1, t+a)), self.add((x1, y1), self.polar(r1, t-a))]
        except:
            # 一方が他方を内包しちゃってる場合等はここに飛ぶ(はず)
            return -1

# 回転行列で座標s,tを回転
def rotate(s, t, dig):
    from math import sin, cos, radians

    x1, y1 = s
    x2, y2 = t
    # sを軸としてtを左回りにdig度回転させた座標(x3,y3)
    x3 = x1 + (x2-x1) * cos(radians(dig)) - (y2-y1) * sin(radians(dig))
    y3 = y1 + (x2-x1) * sin(radians(dig)) + (y2-y1) * cos(radians(dig))
    return (x3, y3)

x = INT()

gm = Geometry(EPS)
cur = (0, 0)
d = (0, 1)
ans = 0
while 1:
    cur = gm.add(cur, d)
    ans += 1
    if abs(cur[0]) < EPS and abs(cur[1]) < EPS:
        break
    d = rotate((0, 0), d, x)
print(ans)

Submission status: Accepted

Solution code:
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

class Geometry:
    """ 幾何学計算用クラス """

    def __init__(self, EPS):
        self.EPS = EPS

    def add(self, a, b):
        x1, y1 = a
        x2, y2 = b
        return (x1+x2, y1+y2)

    def sub(self, a, b):
        x1, y1 = a
        x2, y2 = b
        return (x1-x2, y1-y2)

    def mul(self, a, b):
        x1, y1 = a
        if not isinstance(b, tuple):
            return (x1*b, y1*b)
        x2, y2 = b 
        return (x1*x2, y1*y2)

    def div(self, a, b):
        x1, y1 = a
        if not isinstance(b, tuple):
            return (x1/b, y1/b)
        x2, y2 = b
        return (x1/x2, y1/y2)

    def abs(self, a):
        from math import hypot
        x1, y1 = a
        return hypot(x1, y1)

    def norm(self, a):
        x, y = a
        return x**2 + y**2

    def dot(self, a, b):
        x1, y1 = a
        x2, y2 = b
        return x1*x2 + y1*y2

    def cross(self, a, b):
        x1, y1 = a
        x2, y2 = b
        return x1*y2 - y1*x2

    def project(self, seg, p):
        """ 線分segに対する点pの射影 """

        p1, p2 = seg
        base = self.sub(p2, p1)
        r = self.dot(self.sub(p, p1), base) / self.norm(base)
        return self.add(p1, self.mul(base, r))

    def reflect(self, seg, p):
        """ 線分segを対称軸とした点pの線対称の点 """

        return self.add(p, self.mul(self.sub(self.project(seg, p), p), 2))

    def ccw(self, p0, p1, p2):
        """ 線分p0,p1から線分p0,p2への回転方向 """

        a = self.sub(p1, p0)
        b = self.sub(p2, p0)
        # 反時計回り
        if self.cross(a, b) > self.EPS: return 1
        # 時計回り
        if self.cross(a, b) < -self.EPS: return -1
        # 直線上(p2 => p0 => p1)
        if self.dot(a, b) < -self.EPS: return 2
        # 直線上(p0 => p1 => p2)
        if self.norm(a) < self.norm(b): return -2
        # 直線上(p0 => p2 => p1)
        return 0

    def intersect(self, seg1, seg2):
        """ 線分seg1と線分seg2の交差判定 """

        p1, p2 = seg1
        p3, p4 = seg2
        return (
            self.ccw(p1, p2, p3) * self.ccw(p1, p2, p4) <= 0
            and self.ccw(p3, p4, p1) * self.ccw(p3, p4, p2) <= 0
        )

    def get_distance_PP(self, p1, p2):
        from math import hypot

        x1, y1 = p1
        x2, y2 = p2
        return hypot(x1-x2, y1-y2)

    def get_distance_LP(self, line, p):
        """ 直線lineと点pの距離 """

        p1, p2 = line
        return abs(self.cross(self.sub(p2, p1), self.sub(p, p1)) / self.abs(self.sub(p2, p1)))

    def get_distance_SP(self, seg, p):
        """ 線分segと点pの距離 """

        p1, p2 = seg
        if self.dot(self.sub(p2, p1), self.sub(p, p1)) < 0: return self.abs(self.sub(p, p1))
        if self.dot(self.sub(p1, p2), self.sub(p, p2)) < 0: return self.abs(self.sub(p, p2))
        return self.get_distance_LP(seg, p)

    def get_distance_SS(self, seg1, seg2):
        """ 線分seg1と線分seg2の距離 """

        p1, p2 = seg1
        p3, p4 = seg2
        if self.intersect(seg1, seg2): return 0
        return min(
            self.get_distance_SP(seg1, p3), self.get_distance_SP(seg1, p4),
            self.get_distance_SP(seg2, p1), self.get_distance_SP(seg2, p2),
        )

    def get_cross_pointSS(self, seg1, seg2):
        """ 線分seg1と線分seg2の交点 """

        p1, p2 = seg1
        p3, p4 = seg2
        if not self.intersect(seg1, seg2): return (INF, INF)
        if p1 == p2: return p2
        if p3 == p4: return p3
        base = self.sub(p4, p3)
        dist1 = abs(self.cross(base, self.sub(p1, p3)))
        dist2 = abs(self.cross(base, self.sub(p2, p3)))
        t = dist1 / (dist1+dist2)
        return self.add(p1, self.mul(self.sub(p2, p1), t))

    def intersectCL(self, c, line):
        """ 円cと直線lineの交差判定 """

        x, y, r = c
        return self.get_distance_SP(line, (x, y)) <= r

    def get_cross_pointCL(self, c, line):
        """ 円cと直線lineの交点 """
        from math import sqrt

        if not self.intersectCL(c, line): return -1
        x, y, r = c
        p1, p2 = line
        pr = self.project(line, (x, y))
        e = self.div(self.sub(p2, p1), self.abs(self.sub(p2, p1)))
        base = sqrt(r*r - self.norm(self.sub(pr, (x, y))))
        return [self.add(pr, self.mul(e, base)), self.sub(pr, self.mul(e, base))]

    def arg(self, p):
        from math import atan2
        x, y = p
        return atan2(y, x)

    def polar(self, a, r):
        from math import sin, cos
        return (cos(r)*a, sin(r)*a)

    def intersectCC(self, c1, c2):
        """ 円c1と円c2の交差判定 """
        from math import hypot

        x1, y1, r1 = c1
        x2, y2, r2 = c2
        return hypot(x1-x2, y1-y2) <= r1 + r2
    
    def get_cross_pointCC(self, c1, c2):
        """ 円c1と円c2の交点 """
        from math import acos

        if not self.intersectCC(c1, c2): return -1
        x1, y1, r1 = c1
        x2, y2, r2 = c2
        try:
            d = self.abs(self.sub((x1, y1), (x2, y2)))
            a = acos((r1*r1+d*d-r2*r2) / (2*r1*d))
            t = self.arg(self.sub((x2, y2), (x1, y1)))
            return [self.add((x1, y1), self.polar(r1, t+a)), self.add((x1, y1), self.polar(r1, t-a))]
        except:
            # 一方が他方を内包しちゃってる場合等はここに飛ぶ(はず)
            return -1

# 回転行列で座標s,tを回転
def rotate(s, t, dig):
    from math import sin, cos, radians

    x1, y1 = s
    x2, y2 = t
    # sを軸としてtを左回りにdig度回転させた座標(x3,y3)
    x3 = x1 + (x2-x1) * cos(radians(dig)) - (y2-y1) * sin(radians(dig))
    y3 = y1 + (x2-x1) * sin(radians(dig)) + (y2-y1) * cos(radians(dig))
    return (x3, y3)

x = INT()

gm = Geometry(EPS)
cur = (0, 0)
d = (0, 1)

ans = 0
while 1:
    cur = gm.add(cur, d)
    ans += 1
    if abs(cur[0]) < EPS and abs(cur[1]) < EPS:
        break
    d = rotate((0, 0), d, x)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
y=x=int(input())
while y%360:y+=x
print(y//x)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
x=int(input())
k=1
while k*x%360:k+=1
print(k)

Submission status: Accepted

Solution code:
x = int(input())
xSum = 0
cnt = 1

while True:
  xSum += x
  if xSum%360 == 0:
    break
  cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import math
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()

def main():
    X = ii()
    print(360//math.gcd(X,360))

if __name__ == "__main__":
  main()