POJ 1850 1496 組合數學

2021-06-22 05:07:45 字數 1179 閱讀 3525

poj 1496 word index

poj 1850 code

題意: 

1. 每個詞是自增的 

2. 同樣長度的詞是按字典序排練的 

3. 我們把這些詞標序 

求某個詞的序號

分析: 

組合數學... 

推出公式然後用楊輝三角打錶出組合數,具體看 

我還是太弱orz...

**:1496:

/*

* author: illuz * file: 1496.cpp

* create date: 2014-05-24 23:38:54

* descripton:

*/#include #include #include const int n = 27;

int c[n][n], len, sum;

char str[11];

void init()

int main()

if (!flag)

continue;

sum = 1;

for (int i = 1; i < len; i++)

for (int i = 0; i < len; i++)

} printf("%d\n", sum);

} return 0;

}

1850:

/*

* author: illuz * file: 1850.cpp

* create date: 2014-05-24 23:10:11

* descripton:

*/#include #include #include const int n = 27;

int c[n][n], len, sum;

char str[11];

void init()

int main()

sum = 1;

for (int i = 1; i < len; i++)

for (int i = 0; i < len; i++)

} printf("%d\n", sum);

return 0;

}

poj3252 組合數學

題意 給出乙個範圍,然後問這個範圍內有幾個是round number round number也就是轉化二進位制後,的個數大於等於 的個數 思路 這是乙個組合計數的問題 我們拿乙個二進位制長度為 的數舉例子 如果長度為 那麼所有長度為 以下的數字,肯定都是在範圍內的,那麼我們就要找出所有符合條件的數...

poj3252組合數學

題意 乙個數轉換成二進位制數,零的個數大於等於一的個數的數稱為圓數,例如9轉換成1001,0的個數為2,1的個數為2,所以9為圓數 輸入兩個數start和end,問start到end有多少個圓數。思路 start到end中有多少個圓數,我們只需要求出num 0,start 和num 0,end nu...

poj1850組合數學

題意 給你乙個字串s,輸出s在字典序全排列中的位置 從小到大排列 思路 長度為m的字串有c 26,m 這是顯而易見的,從26個字母中挑m個,因為要公升序排列,所以只有一種排法,即c 26,m 為個數 這樣我們就可以求出長度比字串s小的字串有多少個。len為字串s的長度。長度相同但排在字串s前面的有多...