백준 1684 같은 나머지 (Python, Pypy)

Joowan Park·2023년 7월 30일
0

코딩

목록 보기
12/28
#1684 같은 나머지

import sys
import math

input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
#혹시 모를 중복을 미리 set을 사용하여 제거#
A = list(set(A))
B = []
 
for i in range (0,len(A)-1):
    for j in range (i+1,len(A)):
        b = A[j] - A[i]
        B.append(b)
gcd = B[0]
for i in range (1,len(B)):
    gcd = math.gcd(gcd,B[i])

print(gcd)

나머지가 같게 된다는 것에서 착목할 수 있는 간단한 문제

profile
Complex Dynamics에서 탈출한 원숭이

0개의 댓글