DMOPC '21 Contest 5 P2 - Permutations & Primes
View as PDFGiven an integer , find any permutation 
 of 
 such that 
 is not prime for every integer 
, or report that no such permutation exists.
Constraints
Input Specification
The first and only line of input contains a single integer .
Output Specification
If there exists no valid permutation, output  on a line by itself.
Otherwise, output  space-separated integers on a single line, representing a permutation 
 of 
 where no prefix sum is prime.
Sample Input
5
Sample Output
4 5 3 2 1
Explanation
The prefix sums are: , 
, 
, 
, and 
.
None of , 
, 
, 
, or 
 are prime, so this is a valid permutation.
Comments