日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

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

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

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

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; }


生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 九九热视频在线 | 日韩一区二区三区高清 | 国内精品一区二区 | 国产网站在线 | 91亚洲国产 | 波多野结衣国产 | 三级黄色片欧美 | 国产一区久久久 | 三级免费黄 | 国产日韩一区二区三区 | 国产伦精品一区二区三区免 | 精品一区二区三区免费毛片爱 | 99精品国产免费久久久久久按摩 | 性做久久久久久久免费看 | 亚洲一区二区免费 | 99re在线视频 | 久久免费网 | 九九热视频在线观看 | 欧美在线一 | 黄色在线观看视频免费 | 亚洲天堂成人 | 美国黄色毛片女人性生活片 | 国产四区| 欧美性猛交xxxx黑人交 | 久久精品国产视频 | 国产激情在线观看 | 欧美精品性生活 | 免费一看一级毛片 | 一区二区三区日韩欧美 | 波多野结衣中文字幕久久 | 久久精品毛片 | 性毛片 | 国产欧美日韩在线观看 | 久久艹精品 | 97成人在线视频 | 国产成人8x视频一区二区 | 7777久久香蕉成人影院 | 一区二区三区免费 | 精品久久久久一区二区国产 | 91在线精品秘密一区二区 | 不卡在线一区二区 |