Construct reverse order number

Source: Internet
Author: User

Description

The world famous scientist Innokentiy almost finished the creation of Perpetuum Mobile. Its main part was the energy generator which allows, the other mobile's parts work. The generator consists of a long parallel plates with n lasers on one of them and n receivers on another. The generator is considered to being working if each laser emits the beam-some receiver such that exactly one beam is emit Ted to each receiver.

It is obvious this some beams emitted by distinct lasers can intersect. If the beams intersect each other, one joule of energy is released per second because of the interaction of the beams. The more beams intersect and the more energy is released. Innokentiy noticed that if the energy generator releases exactly K Joules per second, the perpetuum m Obile'll work up to ten times longer. The scientist can direct any laser at no receiver, but he hasn ' t thought of such a construction that would give exactly th E Required amount of energy yet. You should help the scientist to tune up the generator.

Input

The only line contains the integers n and K (1≤ n ≤200000, ) Separated by space-the number of lasers in the energy generator and the power of the generator innokentiy wants to REAC H.

Output

Output n integers separated by spaces. I-th number should is equal to the number of receiver which the i-th laser should be directe D at. Both lasers and receivers is numbered from 1 to n. It's guaranteed that the solution exists. If There is several solutions, you can output any of them.

Sample Input

Input
4 5
Output
4 2 3 1

Input
5 7
Output
4 2 5) 3 1

Input
6 0
Output
1 2 3 4 5 6



Ideas :
The number of the first position can be constructed i-1 the number of reverse order, when the number of inverse number of the structure is less than your target reverse order number can be put in.

1#include <iostream>2 using namespacestd;3 #defineMAXN 200000+54 Long LongXU[MAXN];5 intMain ()6 {7     Long Longn,k;8CIN >> N >>K;9     intnum =1, KO = n-1;Ten      while(KO >=0) One     {  A         if(k >= KO)//the number of reverse order is less than the target reverse number. -         { -K-=Ko; theXu[ko] = num++;//let's start from the back . -         } -ko--; -     } +      for(inti =0; I < n; i++) -     { +         if(Xu[i])//put the number Acout << Xu[i] <<" ";//just output that number . at         Else -cout<<num++<<" ";//otherwise it will output the original number. -     } -     return 0; -}



Construct reverse order number

Related Article

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.