Sum of a Sequence
InterviewTime limit1sMemory limit256 MB
Given an N by N table holding Ai+Aj for every pair of distinct indices and 0 on the diagonal, recover the original positive sequence A.
- Level
Medium5 of 10
- Topics
- Math, Array, Implementation, Brute force
- Solved
- No attempts yet
Problem
There is a sequence of positive integers of length . You are given a table that collects the sum of every pair of distinct elements of the sequence. That is, when , and when .
Given the table , write a program that reconstructs the original sequence .
Input
The first line contains the length of the sequence . ()
Each of the next lines contains integers. The -th integer on the -th line is , where when and when . Every element of the sequence is a positive integer not greater than .
The sequence corresponding to the given table is always unique.
Output
Print the elements of the sequence in order on the first line, separated by spaces.