#C14415. Prime Product Calculator

    ID: 44062 Type: Default 1000ms 256MiB

Prime Product Calculator

Prime Product Calculator

You are to implement a program that calculates the product of all prime numbers from a list of integers provided via standard input. A prime number is defined as a natural number greater than 1 that has no positive divisors other than 1 and itself. In other words, a number \(p\) is prime if and only if it cannot be written in the form \(p = ab\) for any integers \(a, b > 1\).

The program should read input from stdin and output the result to stdout. The input will consist of an integer representing the number of elements in the list, followed by the list elements separated by spaces.

Your program must handle the following cases:

  • If the input list is empty (i.e. the count is 0), output: "Error: Input list is empty."
  • If any of the provided tokens is not a valid integer, output: "Error: Invalid input."
  • If there are no prime numbers in the list, output: "Error: No prime numbers in the list."
  • If at least one prime number is found, output the product of all prime numbers.

inputFormat

The input is provided via standard input and follows this format:

N
x1 x2 x3 ... xN

Where:

  • N is an integer representing the number of elements in the list.
  • x1, x2, ..., xN are the list elements. Each element should be a valid integer.

outputFormat

The output should be written to standard output and is as follows:

  • If the list is empty: Error: Input list is empty.
  • If any element is not a valid integer: Error: Invalid input.
  • If there are no prime numbers in the list: Error: No prime numbers in the list.
  • If there is at least one prime number, output the product of all prime numbers.
## sample
5
2 3 4 5 6
30