728x90
https://www.acmicpc.net/problem/6749
문제
You know a family with three children. Their ages form an arithmetic sequence: the difference in ages between the middle child and youngest child is the same as the difference in ages between the oldest child and the middle child. For example, their ages could be 5, 10 and 15, since both adjacent pairs have a difference of 5 years.
Given the ages of the youngest and middle children, what is the age of the oldest child?
입력
The input consists of two integers, each on a separate line. The first line is the age Y of the youngest child (0 ≤ Y ≤ 50). The second line is the age M of the middle child (Y ≤ M ≤ 50).
출력
The output will be the age of the oldest child.
728x90
예제 입력 1
12
15
예제 출력 1
18
# 둘째, 셋째의 나이 차이와 첫째, 둘째 나이 차이가 같다.
# 둘째, 셋째의 나이를 줄테니 첫째의 나이를 구하라
youngest = int(input())
mid = int(input())
sub = mid - youngest
print(mid + sub)
728x90
'Problem Solving > BOJ' 카테고리의 다른 글
[백준, BOJ 9653] 스타워즈 로고 (python) (0) | 2021.11.18 |
---|---|
[백준, BOJ 8370] Plane (python) (0) | 2021.11.18 |
[백준, BOJ 5554] 심부름 가는 길 (python) (0) | 2021.11.17 |
[백준, BOJ 5522] 카드 게임 (python) (0) | 2021.11.17 |
[백준, BOJ 5339] 콜센터 (python) (0) | 2021.11.16 |