多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > 互聯網 > Codeforces Round #144 (Div. 2)---A. Perfect Permutation

Codeforces Round #144 (Div. 2)---A. Perfect Permutation

來源:程序員人生   發布時間:2014-11-10 08:33:59 閱讀次數:3011次

Perfect Permutation
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

permutation is a sequence of integers p1,?p2,?...,?pn, consisting of n distinct positive integers, each of them doesn't exceed n. Let's denote the i-th element of permutation p as pi. We'll call number n the size of permutation p1,?p2,?...,?pn.

Nickolas adores permutations. He likes some permutations more than the others. He calls such permutations perfect. A perfectpermutation is such permutation p that for any i (1?≤?i?≤?n) (n is the permutation size) the following equations hold ppi?=?i and pi?≠?i. Nickolas asks you to print any perfect permutation of size n for the given n.

Input

A single line contains a single integer n (1?≤?n?≤?100) ― the permutation size.

Output

If a perfect permutation of size n doesn't exist, print a single integer ⑴. Otherwise print n distinct integers from 1 to np1,?p2,?...,?pn ― permutation p, that is perfect. Separate printed numbers by whitespaces.

Sample test(s)
input
1
output
input
2
output
2 1
input
4
output
2 1 4 3




解題思路:貪心。直接構造。如果n為奇數,則不能構成滿足要求的排列;否則,兩個兩個的構造,如2,1;4,3。。。以此類推便可。







AC代碼:

#include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <math.h> #include <stdlib.h> #include <time.h> using namespace std; #define INF 0x7fffffff int main() { #ifdef sxk freopen("in.txt","r",stdin); #endif int n; while(scanf("%d",&n)!=EOF) { if(n&1){ printf("⑴ "); continue; } else{ for(int i=1; i<n/2; i++) printf("%d %d ", 2*i, 2*i⑴); printf("%d %d ", n, n⑴); } } return 0; }


生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 激情久久久久久久久久久 | 自拍偷拍 欧美日韩 | 欧美一区二区三区久久久 | 欧美 亚洲 中文字幕 | h视频免费网站 | 综合涩| 日本一级毛片在线看 | 国产日韩欧美综合一区二区三区 | 国产亚洲精品国产福利在线观看 | 精品一区二区三区免费观看 | 91精品久久久久亚洲国产 | 国产精品极品美女自在线看免费一区二区 | 伊人院| 91福利国产在线观看香蕉 | 日本不卡视频一区二区 | 精品久久精品久久 | 黑人疯狂做人爱视频 | 在线观看免费xx高清视频 | 清纯唯美亚洲综合五月天 | 久久亚洲美女久久久久 | 日韩精品久久久毛片一区二区 | 乌克兰xxxx| 精品国产免费一区二区三区五区 | 午夜dj视频在线观看免费 | 伊人不卡久久大香线蕉综合影院 | 国产一级做a爱片久久毛片a | 色综合久久综合欧美综合网 | 免费观看一级欧美在线视频 | 性freexxxxhd欧美在线 | 亚洲综合日韩欧美一区二区三 | 日本护士handjob| 国产午夜毛片v一区二区三区 | 91精品国产99久久 | 日韩成人精品日本亚洲 | 国产在线一区二区视频 | 欧美亚洲日本在线 | 亚洲欧美日韩综合二区三区 | 亚洲永久免费网站 | 国产不卡的一区二区三区四区 | 福利一区三区 | 在线国产小视频 |