#C14853. Prime Number Check and Dictionary Generation

    ID: 44548 Type: Default 1000ms 256MiB

Prime Number Check and Dictionary Generation

Prime Number Check and Dictionary Generation

You are given a list of tokens (which may or may not represent integers). Your task is to build a dictionary (or mapping) that contains each unique integer from the list as a key and a boolean value indicating whether the number is prime. A number is considered prime if it is greater than 1 and has no positive divisors other than 1 and itself. Non‐integer tokens must be ignored.

Note: The output dictionary should maintain the order of first occurrence of the valid integers as they appear in the input.

The mathematical definition of a prime can be expressed in LaTeX as:

\( n > 1 \text{ and } \forall d \in \mathbb{Z}, \ (1 < d < n \Rightarrow d \nmid n) \).

inputFormat

The first line contains a single integer n, representing the number of tokens. The second line contains n tokens separated by spaces. These tokens may represent integers or non-integer values.

Example:

13
2 3 4 5 6 7 8 9 10 11 12 a 15

outputFormat

Output a dictionary in the format of a Python literal. The dictionary should map each valid integer (in the order of appearance) to either True if the number is prime or False otherwise.

Example:

{2: True, 3: True, 4: False, 5: True, 6: False, 7: True, 8: False, 9: False, 10: False, 11: True, 12: False, 15: False}
## sample
13
2 3 4 5 6 7 8 9 10 11 12 a 15
{2: True, 3: True, 4: False, 5: True, 6: False, 7: True, 8: False, 9: False, 10: False, 11: True, 12: False, 15: False}