第六届蓝桥杯软件类省赛真题-C-B-7_牌型种数

//第六届蓝桥杯软件类省赛真题-C-B-7_牌型种数.cpp 
/*
【题目】 

牌型种数

小明被劫持到X赌城,被迫与其他3人玩牌。
一副扑克牌(去掉大小王牌,共52张),均匀发给4个人,每个人13张。
这时,小明脑子里突然冒出一个问题:
如果不考虑花色,只考虑点数,也不考虑自己得到的牌的先后顺序,
自己手里能拿到的初始牌型组合一共有多少种呢?

请填写该整数,不要填写任何多余的内容或说明文字。

*/

/*【解题思路】
解法一:根据题意可得小明的13张初始牌型组合中至少含有4种牌型,最多含有13种牌型,
		然后可以根据这点进行暴力枚举了 
解法二:将暴力枚举算法转化为递归解决,简化代码量 
答案:
2872
*/

#include<iostream>
using namespace std;

int main()
{
	int count = 0;
	int sum = 0;
	for(int a=1;a<=4;a++)
		for(int b=1;b<=4;b++)
			for(int c=1;c<=4;c++)
				for(int d=1;d<=4;d++){
					if(a+b+c+d == 13)//如果4种牌型(a,b,c,d表示这4种牌型)的数量加起来的种数为13则满足题意条件 
					{
						count++;
						cout<<"a_"<<a<<" b_"<<b<<" c_"<<c<<" d_"<<d<<endl;
					}
				}
	cout<<"count_1 = "<<count<<endl;
	sum += count;
	
	count = 0;
	for(int a=1;a<=4;a++)
		for(int b=1;b<=4;b++)
			for(int c=1;c<=4;c++)
				for(int d=1;d<=4;d++)
					for(int e=1;e<=4;e++){
						if(a+b+c+d+e == 13)//如果5种牌型(a,b,c,d,e表示这5种牌型)的数量加起来的种数为13则满足题意条件 
						{
							count++;
						}
					}
	cout<<"count_2 = "<<count<<endl;
	sum += count;
	
	count = 0;
	for(int a=1;a<=4;a++)
		for(int b=1;b<=4;b++)
			for(int c=1;c<=4;c++)
				for(int d=1;d<=4;d++)
					for(int e=1;e<=4;e++)
						for(int f=1;f<=4;f++){
							if(a+b+c+d+e+f == 13)
							{
								count++;
							}
						}
	cout<<"count_3 = "<<count<<endl;
	sum += count;
	
	count = 0;
	for(int a=1;a<=4;a++)
		for(int b=1;b<=4;b++)
			for(int c=1;c<=4;c++)
				for(int d=1;d<=4;d++)
					for(int e=1;e<=4;e++)
						for(int f=1;f<=4;f++)
							for(int g=1;g<=4;g++){
								if(a+b+c+d+e+f+g == 13)
								{
									count++;
								}
							}
	cout<<"count_4 = "<<count<<endl;
	sum += count;
	
	count = 0;
	for(int a=1;a<=4;a++)
		for(int b=1;b<=4;b++)
			for(int c=1;c<=4;c++)
				for(int d=1;d<=4;d++)
					for(int e=1;e<=4;e++)
						for(int f=1;f<=4;f++)
							for(int g=1;g<=4;g++)
								for(int h=1;h<=4;h++){
									if(a+b+c+d+e+f+g+h == 13)
									{
										count++;
									}
								}
	cout<<"count_5 = "<<count<<endl;
	sum += count;
	
	count = 0;
	for(int a=1;a<=4;a++)
		for(int b=1;b<=4;b++)
			for(int c=1;c<=4;c++)
				for(int d=1;d<=4;d++)
					for(int e=1;e<=4;e++)
						for(int f=1;f<=4;f++)
							for(int g=1;g<=4;g++)
								for(int h=1;h<=4;h++)
									for(int i=1;i<=4;i++){
										if(a+b+c+d+e+f+g+h+i == 13)
										{
											count++;
										}
									}
	cout<<"count_6 = "<<count<<endl;
	sum += count;
	
	count = 0;
	for(int a=1;a<=4;a++)
		for(int b=1;b<=4;b++)
			for(int c=1;c<=4;c++)
				for(int d=1;d<=4;d++)
					for(int e=1;e<=4;e++)
						for(int f=1;f<=4;f++)
							for(int g=1;g<=4;g++)
								for(int h=1;h<=4;h++)
									for(int i=1;i<=4;i++)
										for(int j=1;j<=4;j++){
											if(a+b+c+d+e+f+g+h+i+j == 13)
											{
												count++;
											}
										}
	cout<<"count_7 = "<<count<<endl;
	sum += count;
	
	count = 0;
	for(int a=1;a<=4;a++)
		for(int b=1;b<=4;b++)
			for(int c=1;c<=4;c++)
				for(int d=1;d<=4;d++)
					for(int e=1;e<=4;e++)
						for(int f=1;f<=4;f++)
							for(int g=1;g<=4;g++)
								for(int h=1;h<=4;h++)
									for(int i=1;i<=4;i++)
										for(int j=1;j<=4;j++)
											for(int k=1;k<=4;k++){
												if(a+b+c+d+e+f+g+h+i+j+k == 13)
												{
													count++;
												}
											}
	cout<<"count_8 = "<<count<<endl;
	sum += count;
	
	count = 0;
	for(int a=1;a<=4;a++)
		for(int b=1;b<=4;b++)
			for(int c=1;c<=4;c++)
				for(int d=1;d<=4;d++)
					for(int e=1;e<=4;e++)
						for(int f=1;f<=4;f++)
							for(int g=1;g<=4;g++)
								for(int h=1;h<=4;h++)
									for(int i=1;i<=4;i++)
										for(int j=1;j<=4;j++)
											for(int k=1;k<=4;k++)
												for(int l=1;l<=4;l++){
													if(a+b+c+d+e+f+g+h+i+j+k+l == 13)
													{
														count++;
													}
												}
	cout<<"count_9 = "<<count<<endl;
	sum += count;
	
	count = 0;
	for(int a=1;a<=4;a++)
		for(int b=1;b<=4;b++)
			for(int c=1;c<=4;c++)
				for(int d=1;d<=4;d++)
					for(int e=1;e<=4;e++)
						for(int f=1;f<=4;f++)
							for(int g=1;g<=4;g++)
								for(int h=1;h<=4;h++)
									for(int i=1;i<=4;i++)
										for(int j=1;j<=4;j++)
											for(int k=1;k<=4;k++)
												for(int l=1;l<=4;l++)
													for(int m=1;m<=4;m++){
														if(a+b+c+d+e+f+g+h+i+j+k+l+m == 13)
														{
															count++;
														}
													}
	cout<<"count_10 = "<<count<<endl;
	sum += count;
	
	cout<<"自己手里能拿到的初始牌型组合一共有"<<sum<<"种";
	return 0;
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值