본문 바로가기
공부/코딩테스트

백준: 6749번 Next in line (Python3)

by 혼밥맨 2022. 8. 3.
반응형

백준: 6749번 Next in line (Python3)

 

Next in line 성공다국어

 
시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB 5321 4606 4417 86.898%

문제

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.

예제 입력 1

12
15

예제 출력 1

18

답안

1
2
3
4
age1=int(input())
age2=int(input())
 
print(age2 + abs(age1-age2))
cs

반응형

댓글