## CCC '13 J1 - Next in line

View as PDF

Points: 3
Time limit: 3.0s
Memory limit: 256M

Problem type
##### Canadian Computing Competition: 2013 Stage 1, Junior #1

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?

#### Input Specification

The input consists of two integers, each on a separate line. The first line is the age of the youngest child . The second line is the age of the middle child .

#### Output Specification

The output will be the age of the oldest child.

#### Sample Input 1

12
15

#### Output for Sample Input 1

18

#### Sample Input 2

10
10

#### Output for Sample Input 2

10

• commented on Aug. 8, 2024, 4:41 a.m.

Try this O = 2 * M - Y.

• commented on Aug. 8, 2024, 4:41 a.m.

wait

• commented on Aug. 8, 2024, 4:37 a.m. edit 3

Really hard but if you know then you will know. Just follow the Input Specification. And then everything will be easy.

• commented on July 4, 2024, 2:16 a.m. edit 3

I wonder why my program is wrong when I give such form.

y=int(input('enter the number of age of the youngest child:').strip())

m=int(input('enter the number of age of the middle child: ').strip())

o=2*m-y

print(o)

• commented on April 30, 2024, 4:40 p.m.

не могу разобраться

• commented on Jan. 10, 2024, 4:32 a.m.

incredible work I was so sleepy and then I did this question and I erupted with pure joy, blessings be upon you!