Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

Problem hidden on 2014-11-05 07:55:27 by Francky

S3P3 - Arithmetic and Geometric Sequences

no tags 

 

An arithmetic sequence goes from one term to the next by always adding (or subtracting) the same value. For instance, 2, 5, 8, 11, 14,... and 7, 3, –1, –5,... are arithmetic, since you add 3 and subtract 4, respectively, at each step. A geometric sequence goes from one term to the next by always multiplying (or dividing) by the same value. So 1, 2, 4, 8, 16,... and 81, 27, 9, 3, 1, 1/3,... are geometric, since you multiply by 2 and divide by 3, respectively, at each step.
The number added (or subtracted) at each stage of an arithmetic sequence is called the "common difference"
 The number multiplied (or divided) at each stage of a geometric sequence is called the "common ratio"
Given an integer N you will take N numbers determine whether they form  an Arithmetic sequence (and/or) Geometric sequence or not and print their common differnece and common ration 
Print -1 if the sequence doesn't form Arithmetic sequence
The same for Geometric sequence

 

An arithmetic sequence goes from one term to the next by always adding (or subtracting) the same value. For instance, 2, 5, 8, 11, 14,... and 7, 3, –1, –5,... are arithmetic, since you add 3 and subtract 4, respectively, at each step. A geometric sequence goes from one term to the next by always multiplying (or dividing) by the same value. So 1, 2, 4, 8, 16,... and 81, 27, 9, 3, 1, 1/3,... are geometric, since you multiply by 2 and divide by 3, respectively, at each step.

 

The number added (or subtracted) at each stage of an arithmetic sequence is called the "common difference"

 

 The number multiplied (or divided) at each stage of a geometric sequence is called the "common ratio"

 

Given an integer N you will take N numbers determine whether they form  an Arithmetic sequence (and/or) Geometric sequence or not and print their common differnece and common ration 

 

Print -1 if the sequence doesn't form Arithmetic sequence

The same for Geometric sequence

 

 

Input

N : number of following integers .. N>1

N integers all integers are from -100 to 100 inclusive

Output

Four lines

the first line contains 1 if the sequence form an arithmetic sequence , 0 if not

the second line contains the common difference , -1 if not forming arithmetic sequence

the first line contains 1 if the sequence form an geometric sequence , 0 if not

the second line contains the common ratio , -1 if not forming geometric sequence

Example

Input:
5
1 2 3 4 5

Output:
1 1
0 -1
Input:
5
16 8 4 2 1
Output:
0 -1
1 2
Input:
5
5 4 3 2 1
Output:
1 1
0 -1

hide comments
Min_25: 2014-11-05 06:02:19

@mohamed gamal
This problem doesn't refer to the special cases:

(i) The ratio is not integer: 3 2
Should we output "1 2/3" (or "1 3/2") in that case ?

(ii) There are infinite ratios: 0 0
What should we output ?

(iii) The ratio is 0: 1 0 0
Should we assume that the sequence is geometric ?

Without those clarification, this problem is incomplete and ambiguous and should be hidden.

--ans(Francky)--> Email send to psetter ; problem hidden waiting for fix.
@psetter : please leave a new message when description updated.
edit (mail fail :--> SMTP error from remote server after RCPT command:
host: mx2.hotmail.com
Requested action not taken: mailbox unavailable
)
EDIT:
@Francky
Thank you.

Last edit: 2014-11-05 08:46:35
xol odho: 2012-04-02 07:40:22

Is the output four lines? why all examples have just two lines then? Perhaps it should be two lines, each having two integers.


Added by:mohamed gamal
Date:2012-01-27
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:ASM32-GCC MAWK BC C-CLANG NCSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JS-MONKEY JULIA KTLN NIM NODEJS OBJC OBJC-CLANG OCT PICO PROLOG PYPY PYPY3 PY_NBC R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET