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