Problem A
Permuted Arithmetic Sequence

An arithmetic sequence is a list of values where the difference between consecutive values is always the same. For example, $3, 7, 11, 15$ qualifies and so does $25, 15, 5, -5, -15$. However $2, 4, 7$ and $3, 6, 9, 6$ are not arithmetic sequences.


Input begins with an integer, $1 \leq n \leq 100$, on a line by itself. Following this are $n$ lines, each describing a sequence. Each line begins with an integer, $3 \leq m \leq 100$, giving the length of the sequence. This is followed by the $m$ integer values that actually make up the sequence. Each of the sequence integers is in the range $[-10^6,10^6]$.


For each sequence, output a line that says “arithmetic” if the sequence is an arithmetic sequence. Output “permuted arithmetic” if the sequence can be reordered to make an arithmetic sequence. Otherwise, output “non-arithmetic”.

Sample Input 1 Sample Output 1
5 1 2 3 4 5
3 20 6 13
4 5 9 15 19
permuted arithmetic
CPU Time limit 1 second
Memory limit 1024 MB
Statistics Show
License Creative Commons License (cc by-sa)

Please log in to submit a solution to this problem

Log in