#C2812. Array Action

    ID: 46170 Type: Default 1000ms 256MiB

Array Action

Array Action

This problem involves performing a variety of operations on an array based on a given action type t. Given an array A of N integers, you need to perform one of the following tasks as described below:

  • t = 1: Print the array in reverse order with elements separated by spaces.
  • t = 2: Print the sum of the first half of the array. If N is odd, include the middle element in the sum.
  • t = 3: If the array is a palindrome (i.e., it reads the same forwards and backwards), print "Palindrome"; otherwise, print "Not Palindrome".
  • t = 4: Print the difference between the maximum and minimum elements in the array.
  • t = 5: Print the product of all odd-indexed elements (0-indexed) in the array.
  • t = 6: Replace each element by the greatest common divisor (GCD) of the element and the sum of its digits, then print the resulting array.
  • t = 7: Starting at index 0, jump forward by (current_index + current_index + 1). If you reach the last index, print "Done". If you jump out of bounds, print "Out". If a cycle is detected (i.e., you revisit an index), print "Cyclic".

All output should be printed to standard output, and input should be read from standard input.

inputFormat

The first line contains two integers N and t, where N is the number of elements in the array and t is the action type. The second line contains N space-separated integers representing the array A.

outputFormat

Output the result according to the operation specified by the value of t.

## sample
7 1
1 2 3 4 5 6 7
7 6 5 4 3 2 1

</p>