#K52222. List Operation Calculator

    ID: 29262 Type: Default 1000ms 256MiB

List Operation Calculator

List Operation Calculator

Given a list of numbers and an operation to perform, compute the result of the operation. The valid operations are: sum, product, max, and min.

If the list is empty, output None. If an invalid operation is given, output Invalid operation.

The result for sum is the summation of the numbers; for product it is the multiplication of the numbers; for max and min it is the maximum or minimum number respectively.

Input Format: The first line contains a string denoting the operation. The second line contains an integer N, the number of elements in the list. The third line (only if N > 0) contains N space-separated integers.

Output Format: Print the result of applying the operation on the list. Use None if the list is empty, and Invalid operation if the operation is not one of the valid options.

inputFormat

The input is read from standard input (stdin) and consists of:

  • A line with a string representing the operation name.
  • A line with an integer N indicating the number of elements.
  • If N > 0, a line with N space-separated integers.

outputFormat

The output should be printed to standard output (stdout) as a single line containing the result of the operation. In the case of an empty list, output None. For an invalid operation, output Invalid operation.

## sample
sum
4
1 2 3 4
10

</p>