Codeforces-233A Perfect Permutation
来源:互联网 发布:ubuntu emacs 25 编辑:程序博客网 时间:2024/05/17 08:37
A permutation is a sequence of integersp1,p2,...,pn, consisting ofn distinct positive integers, each of them doesn't exceedn. Let's denote thei-th element of permutation p aspi. We'll call numbern the size of permutationp1,p2,...,pn.
Nickolas adores permutations. He likes some permutations more than the others. He calls such permutations perfect. Aperfect permutation is such permutationp that for any i(1≤i≤n) (n is the permutation size) the following equations holdppi=i andpi≠i. Nickolas asks you to print any perfect permutation of sizen for the givenn.
A single line contains a single integer n (1≤n≤100) the permutation size.
If a perfect permutation of size n doesn't exist, print a single integer -1. Otherwise print n distinct integers from 1 to n,p1,p2,...,pn permutationp, that is perfect. Separate printed numbers by whitespaces.
2
2 1
#include"stdio.h"int main(){int n; while(scanf("%d", &n) != EOF) { if(n % 2) { printf("-1\n"); } else { int i; for(i = 1; i <= n; i++) { if(i % 2) { printf("%d", i + 1); } else printf("%d", i - 1); if(i != n) printf(" "); } printf("\n"); } }return 0;}
- Codeforces-233A Perfect Permutation
- CodeForces 233A Perfect Permutation
- Codeforces 233A-Perfect Permutation(规律)
- 233A. Perfect Permutation
- Codeforces 233A Perfect Permutation(完美序列,水题)
- Codeforces Round #144 (Div. 2)---A. Perfect Permutation
- A. Perfect Permutation
- Perfect Permutation
- Perfect Permutation
- codeforces 317 A Perfect Pair
- CodeForces 482A Diverse Permutation
- Codeforces 123A. Prime Permutation
- CodeForces 482A Diverse Permutation
- 【Poj2825】Perfect Permutation 构造
- CodeForces Round 176Div1 A Lucky permutation
- codeforces 482A Diverse Permutation 贪心
- Codeforces 482A Diverse Permutation(构造)
- Diverse Permutation - CodeForces 482 A 水题
- warning: conflicting types for built-in function 'puts'
- 卸载linux系统自带的mysql
- 第12周任务--分段函数求值。
- java专题(一)之多线程
- 航天里面比较好的一些单位
- Codeforces-233A Perfect Permutation
- 前端优化总结
- uniform : local to a program object
- 关于Java自增操作的原子性
- 正宗绝顶酱牛肉的做法
- 第12周项目一任务一图一—星号图
- DedeCMS 之 include/inc_function.php 系统函数
- 星星点灯
- Linux下安装完MySQL后找不到my.cnf文件原因