Kaz's Party
시간 제한2초메모리 제한2048 MB
n명의 친구가 있을 때, 모든 사람이 원하는 음료를 받을 때까지 교환 과정이 걸리는 기대 라운드 수를 최대로 만드는 순열을 찾아 그 값을 출력한다.
문제
Kaz is inviting of his friends over for a party! He has currently prepared the cocktails for them (each friend has ordered a different drink), with friend having a preference for cocktail .
However, Kaz is looking to pull a prank. When handing out drinks if he hands out a drink to the wrong person, he knows the following round of an 'exchange process' will occur: all partygoers who do not have their desired drinks will leave their drinks on a table. All such drinks will be shuffled and handed back in a completely random order to those still in the exchange process. Any participants who receive their desired drink will leave to enjoy the party, while those still with the wrong drink will shuffle again.
To maximize the humor of his prank, Kaz wants the exchange process to take the maximum expected number of rounds. Help Kaz find an assignment of drinks that will maximize this value.
입력
The input consists of a single integer () --- the number of friends invited to the party.
출력
On the first line, output a single real number --- the maximum expected number of rounds.
On the second line, output distinct integers () --- the assignment of the drinks. Here, drink will be handed to friend .
Your answer will be accepted if the output satisfies the following conditions.
- The value of differs from the actual answer by at most absolute or relative error.
- The value of differs from the expected number of rounds given the permutation by at most absolute or relative error.