Q: N, K. Are you sure you want to satisfy the condition that all even values minus the sum of the first absolute values-all even values minus the first and absolute values of the first sum = 2 × K?
Solution: Because the range of K is suitable, it is directly constructed.
Solution code:
1 // file name: 359b. CPP 2 // Author: darkdream 3 // created time: saturday, July 26, 2014, 44 seconds, 4 5 seconds # include <vector> 6 # include <list> 7 # include <map> 8 # include <set> 9 # include <deque> 10 # include <stack> 11 # include <bitset> 12 # include <algorithm> 13 # include <functional> 14 # include <numeric> 15 # include <utility> 16 # include <sstream> 17 # include <iostream> 18 # include <iomanip> 19 # include <cstdio> 20 # include <cmath> 2 1 # include <cstdlib> 22 # include <cstring> 23 # include <ctime> 24 25 using namespace STD; 26 27 int main () {28 int N, K; 29 scanf ("% d", & N, & K); 30 if (k = 0) 31 {32 for (INT I = 1; I <= 2 * n; I ++) 33 printf ("% d", I); 34 return 0; 35} else {36 printf ("% d ", 1 + k, 1); 37 for (INT I = 2; I <= 2 * n; I ++) 38 if (I! = 1 + k) 39 printf ("% d", I); 40} 41 return 0; 42}
View code