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 a1,a2,,a10. For each sequence, he wants to know if it is arithmetic, geometric, or neither. Output the answer to the ith sequence on the ith 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, where a and d are constants.
A geometric sequence is a sequence such that it can be written in the form: a,ar,ar2, where a and r are constants.

It may be helpful to know that in an arithmetic sequence, ai+ai+2=2ai+1 and in a geometric sequence, gigi+2=gi+12.

Constraints

1N100
109ai109

Input Specification

The first line of input is N.
Each of the following N lines contains 10 integers, a1,a2,,a10, a sequence of numbers.

Output Specification

Your output must have N lines such that the answer to the ith sequence is on the ith 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

Copy
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

Copy
arithmetic
geometric
neither
both

Comments

There are no comments at the moment.