BOJ - 3036 - 링

Updated:

import sys

def GCD(A, B):
    if B > A:
        temp = A
        A = B
        B = temp

    while B != 0:
        N = A % B
        A = B
        B = N
    return A

def solution():
    N = int(input())
    ring = list(map(int, sys.stdin.readline().split()))

    A = ring[0]
    for i in range(1, N):
        divison = GCD(A, ring[i])

        print("{0}/{1}".format((A//divison), (ring[i]//divison)))

solution()

https://www.acmicpc.net/problem/3036

Categories:

Updated:

Leave a comment