0
点赞
收藏
分享

微信扫一扫

B. Permutation(思维+构造) Codeforces Round #209 (Div. 2)

河南妞 2022-06-27 阅读 64

原题链接: ​​https://codeforces.com/problemset/problem/359/B​​

B. Permutation(思维+构造) Codeforces Round #209 (Div. 2)_#define
测试样例

Input
1 0
Output
1 2
Input
2 1
Output
3 2 1 4
Input
4 0
Output
2 7 4 6 1 3 5 8

题意: 给你B. Permutation(思维+构造) Codeforces Round #209 (Div. 2)_#define_02个正整数B. Permutation(思维+构造) Codeforces Round #209 (Div. 2)_i++_03B. Permutation(思维+构造) Codeforces Round #209 (Div. 2)_i++_04,其中B. Permutation(思维+构造) Codeforces Round #209 (Div. 2)_#define_05,你需要找到B. Permutation(思维+构造) Codeforces Round #209 (Div. 2)_i++_06~B. Permutation(思维+构造) Codeforces Round #209 (Div. 2)_#define_07的排列数组,使得
B. Permutation(思维+构造) Codeforces Round #209 (Div. 2)_#define_08

解题思路: 由于B. Permutation(思维+构造) Codeforces Round #209 (Div. 2)_#define_05,所以我们如果以B. Permutation(思维+构造) Codeforces Round #209 (Div. 2)_i++_06为相邻之差的话自然也是可以达成任务需求的,所以按照B. Permutation(思维+构造) Codeforces Round #209 (Div. 2)_i++_04的值一次模拟编排即可。

AC代码

/*
*
*
*/
#include<bits/stdc++.h>//POJ不支持

#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=a;i>=n;i--)

using namespace std;

const int inf=0x3f3f3f3f;//无穷大。
const int maxn=1e5;//限定值。
typedef long long ll;

int n,k;
int main(){
while(cin>>n>>k){
//所有绝对值相加得到的与算数值相加再加+2k
int temp=2*k;
rep(i,1,2*n){
if(temp>=2){
cout<<i<<" "<<i+1<<" ";
temp-=2;
i++;
}
else{
cout<<i+1<<" "<<i<<" ";
i++;
}
}
cout<<endl;

}
return 0;
}


举报

相关推荐

0 条评论