程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> hdu(2062)-Subset sequence 組合數學

hdu(2062)-Subset sequence 組合數學

編輯:C++入門知識

題意:求集合{1,2,3...n}的第m個排列子集合。集合的大小按字典樹排。

例兩個元素的排列子集合按字典樹排列是:{1},{1,2},{2},{2,1};


解法:一個一個元素來確定,每次把剩余的元素按大小順序排列在num中,然後根據排列組合原理直接計算下一個位置的元素的大小,直到排列數為0停止;


代碼:

/******************************************************
* 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-8
const 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

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved