본문 바로가기

백준

[백준]Next in line 6749 python

Next in line 출처다국어분류

시간 제한메모리 제한제출정답맞은 사람정답 비율

1 초 128 MB 1257 1108 1038 88.718%

문제

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.

 

친절하게 순서대로 나이를 입력해준다.

2명의 나이 차이만큼 제일 성숙한 사람도 중간 나이 사람과 나이 차이가 있다고 한다.

 

a = int(input())
b = int(input())

differ = b - a
print(b + differ)
반응형

'백준' 카테고리의 다른 글

[백준]8370 Plane python  (0) 2021.04.15
[백준]7287 등록 python  (0) 2021.04.14
[백준]5554 심부름 가는 길 python  (0) 2021.04.12
[백준]5552 카드 게임 python  (0) 2021.04.12
[백준]1436 영화감독 숌 python  (0) 2021.01.28