Mock CCC '20 Contest 2 S1 - Arithmetic Hybercube

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 128M

Author:
Problem type

Arithmetic Square, everyone's favourite problem. Welcome to the better problem, Arithmetic Line!

You are given N integers, which are guaranteed to form an arithmetic sequence. However, they appear scrambled! Can you recreate the arithmetic sequence given the N integers?

Recall that an arithmetic sequence of length N is a sequence of integers of the form

a,a+d,a+2d,,a+(N1)d

for integer values of a and d. For the purposes of this problem, d is a non-negative integer.

Input Specification

The first line will contain the integer N (1N100), the number of integers.

The second line will contain N integers, a1,a2,,aN (1ai109), the integers you are given. It is guaranteed that these integers form an arithmetic sequence in some permutation of them.

Output Specification

Output the recreated arithmetic sequence.

Sample Input

Copy
3
7 3 5

Sample Output

Copy
3 5 7

Explanation For Sample

The arithmetic sequence of N=3 integers that is built has a=3 and d=2.


Comments


  • 1
    KAMEHAMEHAMEHA  commented 42 days ago

    For python users: If you were to make a list in this problem to use the sort() function, be sure to get rid of the brackets! :)


  • 0
    HisMonDon  commented on Sept. 1, 2024, 6:45 p.m.

    DON'T FORGET 2 DIGIT/CHARACTER NUMBERS EXIST stared at my code for 10 minutes before i figured that out