首页 > 其他 > 详细

[Water]Hdu 5228 ZCC loves straight flush

时间:2015-06-11 21:10:36      阅读:140      评论:0      收藏:0      [点我收藏+]

枚举法:

#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;
	}
}

  

[Water]Hdu 5228 ZCC loves straight flush

原文:http://www.cnblogs.com/bruce27/p/4570042.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!