Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
Tags
- 다익스트라
- 재귀
- 수학
- DP
- programmers
- 힙
- 백준
- 스택
- 가상메모리
- 가상메모리 관리
- 파이썬
- MYSQL
- level0
- level2
- 그리디
- level3
- 브루트포스
- dfs
- 프로그래머스
- dict
- level1
- BFS
- 딕셔너리
- 구현
- 다이나믹 프로그래밍
- 운영체제
- 코딩테스트
- BOJ
- N과M
- python
Archives
- Today
- Total
동캄의 코딩도장
백준 17087 [숨바꼭질 6] 파이썬 본문
https://www.acmicpc.net/problem/17087
import sys
input = sys.stdin.readline
def gcd(a, b):
while b != 0:
temp = b
b = a % b
a = temp
return a
N, S = map(int, input().split())
lst = list(map(int, input().split()))
answer = abs(S-lst.pop())
for pos in lst:
answer = gcd(answer, abs(S-pos))
print(answer)
gcd를 구현하는 문제이다
'코테 > BOJ' 카테고리의 다른 글
백준 15988 [1, 2, 3 더하기 3] 파이썬 (0) | 2022.02.09 |
---|---|
백준 1309 [동물원] 파이썬 (0) | 2022.02.09 |
백준 1373 [2진수 8진수] 파이썬 (0) | 2022.02.09 |
백준 10809 [알파벳 찾기] 파이썬 (0) | 2022.02.09 |
백준 10808 [알파벳 개수] 파이썬 (0) | 2022.02.09 |