codeforces B. Permutation
2013-11-09 17:34
549 查看
codeforces B. Permutation
解题报告
题目意思:给定n和k的值,需要构造一条长度为2n(每个元素取值范围只能是[1,2n])且元素各不相同的序列,这条序列符合等式![](http://espresso.codeforces.com/b54693338584d5268d5ec3ab8c4f8e90b87dea39.png)
![](http://espresso.codeforces.com/b54693338584d5268d5ec3ab8c4f8e90b87dea39.png)
1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 using namespace std; 5 6 int main() 7 { 8 int n, k, i, j; 9 while (scanf("%d%d", &n, &k) != EOF) 10 { 11 if (k != 0) 12 { 13 j = 2 * n - k; 14 printf("%d %d ", j, 2 * n); 15 for (i = 2 * n - 1; i >= 1; i--) 16 { 17 if (i != j) 18 printf("%d ", i); 19 } 20 } 21 else 22 { 23 for (i = 2 * n; i >= 1; i--) 24 printf("%d ", i); 25 } 26 printf("\n"); 27 } 28 return 0;
相关文章推荐
- Codeforces 691D. Swaps in Permutation (并查集 + 优先队列)
- Lucky Permutation Triple CodeForces - 303A
- 【CodeForces】500B - New Year Permutation(Floyd)(贪心)
- CodeForces 233A Perfect Permutation
- Codeforces 612E - Square Root of Permutation (置换+构造)
- 【CodeForces】500B - New Year Permutation(Floyd)(贪心)
- Codeforces 864D - Make a Permutation! 【贪心】
- 【CodeForces】500B - New Year Permutation(Floyd)(贪心)
- [Hash] Codeforces 452F MemSQL Start[c]UP 2.0 - Round 1 F. Permutation
- Codeforces 864D D. Make a Permutation!【思维+线段树+二分+这是一个煞笔做法】
- Codeforces 500B - New Year Permutation(最短路)
- CodeForces - 359B Permutation
- Codeforces-137B-Permutation
- [Codeforces 864D]Make a Permutation!
- 【CodeForces 500B】【贪心】New Year Permutation
- Codeforces 804E The same permutation(构造)
- Codeforces 864 D Make a Permutation!
- Codeforces 500B - New Year Permutation (思维)
- CodeForces 500B Good Bye 2014 New Year Permutation
- CodeForces 676A Nicholas and Permutation(移动数字游戏)