#C4276. Replace Primes and Multiples of Five
Replace Primes and Multiples of Five
Replace Primes and Multiples of Five
Given a list of integers, your task is to modify the list as follows: Replace every prime number by the string prime
and every multiple of 5 by five
. If a number is both prime and a multiple of 5, replace it with prime-five
. A prime number is defined as a positive integer greater than 1 that has no divisors other than 1 and itself (i.e. \(n > 1\) and only divisible by 1 and \(n\)).
The program should read input from stdin and output the result to stdout. The input must be provided in the following format: The first line contains a single integer \(T\) (the number of elements in the list). The second line contains \(T\) space-separated integers. If the input does not follow this specification or contains non-integer values, output the error message Please enter a valid list of integers.
inputFormat
The first line of input is an integer \(T\) representing the number of elements. The second line contains \(T\) space-separated integers. For example:
6 2 5 10 15 17 20
If the input format is incorrect (for instance, missing numbers or non-integer tokens), output the error message.
outputFormat
If the input is valid, output a single line with the modified list elements separated by a single space. For an empty list (i.e. \(T = 0\)), output an empty line. Otherwise, print Please enter a valid list of integers.
## sample6
2 5 10 15 17 20
prime prime-five five five prime five