CF233A.Perfect Permutation
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A permutation is a sequence of integers _p_1, _p_2, ..., p__n, consisting of n distinct positive integers, each of them doesn't exceed n. Let's denote the i-th element of permutation p as p__i. We'll call number n the size of permutation _p_1, _p_2, ..., p__n.
Nickolas adores permutations. He likes some permutations more than the others. He calls such permutations perfect. A perfect permutation is such permutation p that for any i (1 ≤ i ≤ n) (n is the permutation size) the following equations hold p__p__i = i and p__i ≠ i. Nickolas asks you to print any perfect permutation of size n for the given n.
排列是指由 n 个互不相同的正整数构成的序列 p1,p2,…,pn,且每个数均不超过 n。我们用 pi 表示排列 p 的第 i 个元素。我们将 n 称为排列 p1,p2,…,pn 的长度。
尼古拉喜欢排列,其中他尤其钟爱某些排列,称其为完美排列。一个完美排列 p 是指:对任意 i(1≤i≤n,其中 n 为该排列的长度),均满足以下两个等式:
ppi=i且pi=i.
尼古拉请你针对给定的 n,输出任意一个长度为 n 的完美排列。
输入格式
A single line contains a single integer n (1 ≤ n ≤ 100) — the permutation size.
一行包含一个整数 n(1≤n≤100)——排列的长度。
输出格式
If a perfect permutation of size n doesn't exist, print a single integer -1. Otherwise print n distinct integers from 1 to n, _p_1, _p_2, ..., p__n — permutation p, that is perfect. Separate printed numbers by whitespaces.
如果不存在大小为 n 的完美排列,则输出单个整数 -1。否则,输出 n 个互不相同的、取值范围在 1 到 n 之间的整数 p1,p2,...,pn —— 即一个完美排列 p。输出的数字之间用空格分隔。
输入输出样例
输入#1
1
输出#1
-1
输入#2
2
输出#2
2 1
输入#3
4
输出#3
2 1 4 3
输入解题思路,AI测评打分。不知道怎么写?