#C2163. Harmonically Aligned Sequences

    ID: 45449 Type: Default 1000ms 256MiB

Harmonically Aligned Sequences

Harmonically Aligned Sequences

You are given a sequence of positive numbers \(a_1, a_2, \dots, a_n\). The sequence is said to be harmonically aligned if all consecutive ratios are equal, i.e. \(\frac{a_2}{a_1} = \frac{a_3}{a_2} = \cdots = \frac{a_n}{a_{n-1}}\). If the sequence contains fewer than 3 elements, consider it harmonically aligned by definition.

If the given sequence is not harmonically aligned, you are allowed to remove exactly one element from the sequence. Your task is to determine if this single removal can result in a harmonically aligned sequence. If yes, output the 1-indexed position of the removed element (if there are multiple possibilities, output any one valid position). If the sequence is already harmonically aligned, output Aligned. Otherwise, if no single removal can achieve harmonic alignment, output Cannot be aligned.

Note: All ratios should be computed using real number division, and comparisons can be made using an appropriate tolerance for floating-point arithmetic.

inputFormat

The input is read from standard input (stdin) and has the following format:

T
n
a1 a2 ... an
... (repeated T times)

Here, T is the number of test cases. For each test case, the first line contains an integer n (the length of the sequence), followed by a line of n space-separated positive numbers.

outputFormat

For each test case, output a single line. The line should contain either:

  • Aligned if the sequence is already harmonically aligned,
  • a number (1-indexed) representing the position of the element that can be removed to achieve harmonic alignment, or
  • Cannot be aligned if no single removal can result in harmonic alignment.

The result for each test case should be printed on a separate line to stdout.

## sample
1
5
2 4 8 16 32
Aligned

</p>