[문제]
https://www.acmicpc.net/problem/2997
2997번: 네 번째 수
첫째 줄에 상근이가 고른 네 개의 숫자 중 세 개가 주어진다. 이 숫자는 크기 순이 아닐 수도 있고, -100보다 크거나 같고, 100보다 작거나 같은 정수이다.
www.acmicpc.net
[풀이]
[코드]
import sys
if __name__ == '__main__':
temp = sorted(list(map(int, sys.stdin.readline().split())))
first_d = temp[1] - temp[0]
second_d = temp[2] - temp[1]
if first_d == second_d:
print(temp[2] + second_d)
elif first_d < second_d:
print(temp[2] - min(first_d, second_d))
else:
print(temp[1] - min(first_d, second_d))
'문제풀이 > BOJ' 카테고리의 다른 글
[Python] BOJ/백준 2547번 사탕 선생 고창영 (1) | 2021.07.15 |
---|---|
[Python] BOJ/백준 1864번 문어 숫자 (0) | 2021.07.15 |
[Python] BOJ/백준 1652번 누울 자리를 찾아라 (0) | 2021.07.11 |
[Python] BOJ/백준 1252번 이진수 덧셈 (0) | 2021.07.11 |
[Python] BOJ/백준 1225번 이상한 곱셈 (0) | 2021.07.10 |