Hdu (2062)-Subset sequence combined mathematics

Source: Internet
Author: User

Question: Find the m-th sub-set of the set {1, 2, 3... n. The set size is arranged in the dictionary tree.

In this example, the sub-sets of the two elements are arranged in the dictionary tree: {1}, {1}, {2}, {2 };


Solution: determine the number of elements one by one. Each time the remaining elements are arranged in num in order of size, the size of the elements in the next position is calculated based on the principle of arrangement and combination until the number of elements is 0;


Code:

/******************************************************* author:xiefubao*******************************************************/#pragma comment(linker, "/STACK:102400000,102400000")#include 
 
  #include 
  
   #include 
   
    #include 
    
     #include 
     
      #include 
      
       #include #include 
       
        #include 
        #include 
         
          #include 
          
           #include 
           
            //freopen ("in.txt" , "r" , stdin);using namespace std;#define eps 1e-8const double pi=acos(-1.0);typedef long long LL;const int Max=21;const int INF=1000000007;LL A[Max][Max];LL sum[Max];void init(){ for(int i=0; i
            
             

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.