连续扑克牌

这篇博客探讨了一种连续的扑克牌序列现象,分析了其出现的概率和可能的组合策略,涉及概率论和组合数学的知识。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 

#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<stdlib.h>
#include <iostream>
#include <vector>
#include <queue>
using namespace std; 



int main(){
	int i,j,m,k;
    int T;
    cin>>T;
    int sum;
   	for(i=0;i<T;i++){
   		int n;
   		int b[20],a[14]={0};
   		cin>>n;
   		int count=0;
   		sum=0;
   		for(j=0;j<n;j++){
   			char a[2];
   			cin>>a;
   			if(a[0]=='A'){
   				b[j]=1;
			}
			else if(a[0]=='J') b[j]=11;
			else if(a[0]=='Q') b[j]=12;
			else if(a[0]=='K') b[j]=13;
			else if(a[0]=='1' && a[1]=='0') b[j]=10;
			else b[j]=a[0]-'0';
		}
		sort(b,b+n);
		for(j=0;j<n;j++){
			a[b[j]]++;
		}
		int count2=0;
		for(j=1;j<n;j++){
			if(b[j]!=b[count2]){
				count2++;
				b[count2]=b[j];
			}
		}
		for(m=0;m<=count2;m++){
			count=1;
			for(k=m+1;k<=count2;k++){
				if(b[k]==b[k-1]+1){
					count++;
					if(count>=5){
						int zz=1;
						for(int dd=m;dd<=k;dd++){
							zz*=a[b[dd]];			
						}
						sum +=zz;
					}
				}
				else break;				
			}	
		}
		cout<<sum<<endl;
    }
    return 0;
}
/*


1
7
7 3 3 4 4 5 6


5
7
7 3 3 4 4 5 6
5
2 3 4 6 A
5
A 2 3 4 5
6
3 4 5 6 7 8
9
7 5 6 8 8 9 9 10 10



4
0
1
3
20
*/ 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值