Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
Language:
Perfect Permutation
Time Limit: 1000MSMemory Limit: 65536K
Total Submissions: 475Accepted: 212Special Judge

Description

A permutation of 1..n {An} is called a Perfect Permutation if the sequence {|Aii|} is a permutation of 0..(n − 1).
For example, {3, 2, 4, 1} is a perfect permutation for {2, 0, 1, 3} is a permutation of 0..3.
Given an integer n, your mission is to find a perfect permutation of 1..n.

Input

The input consists of several lines. Each line contains a positive integer n ≤ 1000.

Output

The output contains one line for each line in the input. If no such perfect permutation exists, output a single number 0 otherwise the perfect permutation. If more than one solution exist, you can output anyone.

Sample Input

1
2
4

Sample Output

1
0
3 2 4 1

Source

POJ Monthly--2006.04.28, Dagger@PKU_RPWT

[Submit]   [Go Back]   [Status]   [Discuss]

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator