Public submissions
Source code of every submission to this problem in this contest
will be visible for everyone since 2014-03-30 20:30:00.
Submit | All submissions | Best solutions | Back to list |
APSEQ - Adding Number to a Sequence |
Given an array of Integers, you are allowed to add just one number such that some permutation of the resulting array forms an AP. (Arithmetic Progression).
Print all such numbers that you can add for a given array.
A sequence s1,s2,....,sn is in AP if
s2-s1 = s3-s2 = ......= sn-sn-1
Input
First line of input contains t, number of test cases.
First line of every test case is the N (<10^5), size of the array.
Next line contains N numbers.
Output
Output for each test case contains two lines.
First line is the numbers of numbers which satisfies the above condition.
Next line contains all such numbers seperated by single space in increasing order.
If there are infinte such numbers then print -1.
Example
Input: 4
3
1 2 4
1
5
4
4 3 4 5
2
2 4
Output:
1
3
-1
0
3
0 3 6
Added by: | Savan Popat |
Date: | 2014-03-26 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM32-GCC ASM64 MAWK BC C-CLANG NCSHARP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JS-MONKEY JULIA KTLN NIM OBJC OBJC-CLANG OCT PICO PROLOG PYPY PYPY3 R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET |
Public source code since: | 2014-03-30 20:30:00 |
hide comments
2014-03-27 17:15:11 shashank
@rishabh Only Integers..... No Float Last edit: 2014-03-27 17:15:33 |
|
2014-03-27 17:09:12 rishabh sanklecha
can the inserted number be a floating number. example if n=2 and numbers are 1,2 .... can we insert 1.5 in it? |