#P9009. Composite Basic Problems: Odd Count, Prime Check, and Threshold Element

    ID: 22169 Type: Default 1000ms 256MiB

Composite Basic Problems: Odd Count, Prime Check, and Threshold Element

Composite Basic Problems: Odd Count, Prime Check, and Threshold Element

This problem is a composite of three basic tasks. The program will first read an integer Q which determines which sub-problem to solve:

  • Problem 1 [Q = 1]: Given n integers, count the number of odd integers.
  • Problem 2 [Q = 2]: Given an integer p, determine whether it is a prime number. Print Prime if it is, and Composite otherwise.
  • Problem 3 [Q = 3]: Given n integers where the i-th integer is \(a_i\), find the maximum number \(p\) such that the count of numbers satisfying \(a_i \ge p\) is at least \(\lfloor{n/2}\rfloor\). For example, if the list is [3, 1, 4, 1, 5] with \(n=5\), then \(\lfloor{5/2}\rfloor=2\) and the answer is 4 because there are exactly 2 numbers (4 and 5) that are \(\ge 4\).

The input and output formats vary depending on the problem chosen.

inputFormat

The input begins with an integer Q (1 ≤ Q ≤ 3) indicating the problem to solve. The input format for each problem is as follows:

  1. If Q = 1: The next line contains an integer n (the number of integers), followed by a line with n space-separated integers.
  2. If Q = 2: The next line contains a single integer p.
  3. If Q = 3: The next line contains an integer n, followed by a line with n space-separated integers \(a_i\).

outputFormat

Output a single line containing the answer for the selected problem:

  1. For Q = 1: Output the count of odd numbers.
  2. For Q = 2: Output Prime if the given number is prime, or Composite otherwise.
  3. For Q = 3: Output the maximum number \(p\) such that the number of elements \(\ge p\) is at least \(\lfloor\frac{n}{2}\rfloor\).

sample

1
5
2 3 7 8 10
2

</p>