#C8363. Compare Geometric Sequence Sum

    ID: 52337 Type: Default 1000ms 256MiB

Compare Geometric Sequence Sum

Compare Geometric Sequence Sum

Given four numbers a1, r, n, and x, calculate the sum of the first n terms of a geometric sequence where the sum Sn is defined as:

\( S_n = \begin{cases} a_1 \times n & \text{if } r = 1,\\[6pt] a_1 \times \frac{1-r^n}{1-r} & \text{if } r \neq 1 \end{cases} \)

After computing the sum, compare it with the given value x and output one of the following results:

  • GREATER if Sn > x
  • EQUAL if Sn = x
  • LESS if Sn < x

This problem tests your ability to work with geometric progressions and precision in arithmetic computations.

inputFormat

The input consists of a single line containing four space-separated values: a1, r, n, and x. Here, a1, r, and x can be integer or floating-point numbers, while n is an integer.

outputFormat

Output a single line with one of the strings: GREATER, EQUAL, or LESS, which indicates the comparison result between the computed geometric sum and x.

## sample
1 -1 3 -1
GREATER

</p>