반응형
백준: 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 |
반응형
'공부 > 코딩테스트' 카테고리의 다른 글
백준: 6764번 Sounds fishy! (Python3) (0) | 2022.08.03 |
---|---|
백준: 6763번 Speed fines are not fine! (Python3) (0) | 2022.08.03 |
백준: 5928번 Contest Timing (Python3) (0) | 2022.08.03 |
백준: 9653번 스타워즈 로고 (Python3) (0) | 2022.08.03 |
백준: 5554번 심부름 가는 길 (Python3) (0) | 2022.08.03 |
댓글