牌型种数
1.基本原理
第一种,暴力枚举,也就是13种牌,每种牌被选择的情况为0,1,2,3,4。只要13张牌。
(注意不是单一组合排序,因为会重复,比如1122,求C52(13),会出现不止一次。)
第二种,递归查询,实际也就是step 有13 步,每步会有5中情况,n(表示牌),n+1,n+2,n+3,n+4,直到n=13的时候为递归的基本情况
第三种,动态规划,也就是状态迁移,考虑两个变量(牌的种类,牌收集的个数),使用二维数组,b[x][y] 表示x种牌,要收集y种的情况有多少,也就是我们要求b[13][13]是多少。
2.代码:
2.1for循环
比较容易理解,13种情况,总和是13就可以计数
package four_two;
public class Main02 {
public static void main(String[] args) {
find();
}
static void find() {
int ans = 0;
for (int one = 0; one < 5; one++)//第一种,可以取的种类有5种。
for (int two = 0; two < 5; two++) //第二种
for (int three = 0; three < 5; three++) //第三种
for (int four = 0; four < 5; four++) //第四种
for (int five = 0; five <5; five++)
for (int six