Codeforces359b-permutation Construction

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.