DMOPC '19 Contest 3 P0 - What is it?

View as PDF

Submit solution

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

Author:
Problem type

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

Note:
An arithmetic sequence is a sequence such that it can be written in the form: a, a+d, a+2d, \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, \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.

Constraints

1 \le N \le 100
-10^9 \le a_i \le 10^9

Input Specification

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

Output Specification

Your output must have N lines such that the answer to the i^\text{th} sequence is on the i^\text{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

4
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

arithmetic
geometric
neither
both

Comments

There are no comments at the moment.