[Water]Hdu 5228 ZCC loves straight flush

Enumeration:

#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <queue>
#include <set>
typedef long long ll;

using namespace std;

const int MAXN=100005;

bool has[52];

int f(int start){
	if(start % 13 > 9)return 5;
	int s=5;
	if(has[start])s--;
	if(has[start+1])s--;
	if(has[start+2])s--;
	if(has[start+3])s--;
	if(start % 13==9){
		if(has[start-9])s--;
	}
	else if( has[start+4] )s--;

	return s;

}

int main(){
	int t;
	cin>>t;
	while(t--){
		memset(has,0,sizeof has);
		int w;
		char ch;
		for(int i=0;i<5;i++){
			getchar();
			scanf("%c%d",&ch,&w);
			w=(ch-'A')*13+w-1;
			has[w]=true;
		}
		int ans=10;
		for(int i=0;i<=48;++i){
			ans=min(ans, f(i) );
		}
		cout<<ans<<endl;
	}
}

  

原文地址:https://www.cnblogs.com/bruce27/p/4570042.html