DMOPC '19 Contest 3 P0 - What is it?

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 256M

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

Veshy needs help in math class. He has N sequences of 10 spaced terms in order of a_1, a_2, a_3, \dots, a_{10}. For each sequence he wants to know if it is arithmetic, geometric, or neither. Output the answer to the i^{th} sequence on the i^{th} line. Terms are guaranteed to be integers.

A arithmetic sequence is a sequence such that it can be written in the form: a, a+d, a+2d, a+3d, \dots where a and d are constants.
A geometric sequence is a sequence such that it can be written in the form: a, ar, ar^2, ar^3, \dots where a and r are constants.

It may be helpful to know that in an arithmetic sequence, a_i + a_{i+2} = 2a_{i+1} and in a geometric sequence, g_i \cdot g_{i+2} = g_{i+1}^2


In all tests,
1 \le N \le 100
-10^9 \le a_i \le 10^9

Input Specification

The first line of input is N.
Each the following N lines contains 10 integers, a_1, a_2, a_3, \dots, a_{10}, a sequence of numbers.

Output Specification

Your output must have N lines such that the answer to the i^{th} sequence is on the i^{th} line.
If the sequence is arithmetic, output arithmetic.
If the sequence is geometric, output geometric.
If the sequence is neither arithmetic nor geometric, output neither.
If the sequence is both arithmetic and geometric, output both.

Sample Input

1 2 3 4 5 6 7 8 9 10
2 4 8 16 32 64 128 256 512 1024
1 1 0 0 1 1 0 0 1 1
1 1 1 1 1 1 1 1 1 1

Sample Output



There are no comments at the moment.