COCI '07 Contest 3 #1 Cetiri

View as PDF

Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 32M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Mirko has chosen four integers which form an arithmetic progression. In other words, when the four numbers are sorted, then the difference between each pair of adjacent elements is constant.

As has become usual, Mirko lost one of the numbers and also is not sure whether the remaining three are in the correct (sorted) order.

Write a program that, given the three remaining numbers, finds the fourth number.

Input Specification

The input contains 3 integers between -100 and 100 on a single line, separated by single spaces.

Note: the input data will guarantee that a solution, although not necessarily unique, will always exist.

Output Specification

Output any number which could have been the fourth number in the sequence.

Sample Input 1

4 6 8

Sample Output 1

10

Sample Input 2

10 1 4

Sample Output 2

7

Comments

There are no comments at the moment.