UVA 131 - The Psychic Poker Player

 

 

In 5-card draw poker, a player is dealt a hand of five cards (which may be looked at). The player may then discard between zero and five of his or her cards and have them replaced by the same number of cards from the top of the deck (which is face down). The object is to maximize the value of the final hand. The different values of hands in poker are given at the end of this problem.

Normally the player cannot see the cards in the deck and so must use probability to decide which cards to discard. In this problem, we imagine that the poker player is psychic and knows which cards are on top of the deck. Write a program which advises the player which cards to discard so as to maximize the value of the resulting hand.

 

Input and Output

Input will consist of a series of lines, each containing the initial five cards in the hand then the first five cards on top of the deck. Each card is represented as a two-character code. The first character is the face-value (A=Ace, 2-9, T=10, J=Jack, Q=Queen, K=King) and the second character is the suit (C=Clubs, D=Diamonds, H=Hearts, S=Spades). Cards will be separated by single spaces. Each input line will be from a single valid deck, that is there will be no duplicate cards in each hand and deck.

Each line of input should produce one line of output, consisting of the initial hand, the top five cards on the deck, and the best value of hand that is possible. Input is terminated by end of file.

 

Use the sample input and output as a guide. Note that the order of the cards in the player's hand is irrelevant, but the order of the cards in the deck is important because the discarded cards must be replaced from the top of the deck. Also note that examples of all types of hands appear in the sample output, with the hands shown in decreasing order of value.

 

Sample Input

 

TH JH QC QD QS QH KH AH 2S 6S
2H 2S 3H 3S 3C 2D 3D 6C 9C TH
2H 2S 3H 3S 3C 2D 9C 3D 6C TH
2H AD 5H AC 7H AH 6H 9H 4H 3C
AC 2D 9C 3S KD 5S 4D KS AS 4C
KS AH 2H 3C 4H KC 2C TC 2D AS
AH 2C 9S AD 3C QH KS JS JD KD
6C 9C 8C 2D 7C 2H TC 4C 9S AH
3D 5S 2H QD TD 6S KH 9H AD QH

 

Sample Output

 

Hand: TH JH QC QD QS Deck: QH KH AH 2S 6S Best hand: straight-flush
Hand: 2H 2S 3H 3S 3C Deck: 2D 3D 6C 9C TH Best hand: four-of-a-kind
Hand: 2H 2S 3H 3S 3C Deck: 2D 9C 3D 6C TH Best hand: full-house
Hand: 2H AD 5H AC 7H Deck: AH 6H 9H 4H 3C Best hand: flush
Hand: AC 2D 9C 3S KD Deck: 5S 4D KS AS 4C Best hand: straight
Hand: KS AH 2H 3C 4H Deck: KC 2C TC 2D AS Best hand: three-of-a-kind
Hand: AH 2C 9S AD 3C Deck: QH KS JS JD KD Best hand: two-pairs
Hand: 6C 9C 8C 2D 7C Deck: 2H TC 4C 9S AH Best hand: one-pair
Hand: 3D 5S 2H QD TD Deck: 6S KH 9H AD QH Best hand: highest-card

 

 

 

下面列出从大到小的扑克牌面. 这是所有的扑克通用规则。

1
Royal Flush 同花大顺又称皇家同花顺 它是所有德州扑克中的王牌,即使您经常玩扑克,也很少见到这样的牌。好比打高尔夫球一杆进洞一样。它是由T(10)到Ace的清一色同花组成。Uva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>Player
   
2
Straight Flush 同花顺 除了由最大同花所组成的同花大顺以外的同花组成的顺子。 Uva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>Player
   
3
Four-of-a-Kind 四条 四张同样的牌+任意一张牌 。 Uva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>Player
   
4
 

Full House 俘虏或船牌或葫芦 三条带一对,即三张同样的牌带两张同样的牌。如都是Full House,则先比较谁的三条大,如三条一样大,则比谁的两对大。如:

Uva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>Player
   
5
Flush 五张同花 用五张同一花色但不相连的牌型组成,如都是五张同花,则谁的同花牌大谁赢。 Uva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>Player
   
6
Straight 五张顺子 由五张相连但不同花色的牌组成,在连牌中,Ace是既可作最大也可以作最小的牌。 Uva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>Player
   
7
Three-of-a-Kind 三条 即三张同样的牌。它有两种叫法,取决于一对牌是在您手中还是在桌上。一对在手中,桌上有一张,称之为“set”;v如手中有一张,桌上有一对,则称之为“Three of A Kind”。 Uva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>Player
   
8
Two Pair 两对 由五张牌中的两对牌组成。如果都有两对,则先比大对,再比小对 。 Uva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>Player
   
9
One Pair 一对 当不止一人有同样的一对牌时,则要比一对后面的牌,称之为“Kickers”。记住,德州扑克是挑选最好的五张牌去比。 Uva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>Player
   
10
High Card 大牌 无以上任何牌型时,决定牌的大小 。 Uva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>PlayerUva <wbr> <wbr>131 <wbr>- <wbr>The <wbr>Psychic <wbr>Poker <wbr>Player

 

 

 

 

可以用0-2^5 32个二进制数生成所有弃牌情况用0,1分别代表第x张牌弃还是留,然后从牌堆补到5张;

至于比大小,其实只有三大类,顺子(10 J Q K A特殊),同花,对子(包含多张相同);

统计对子可以将每次产生的五张牌分别统计与每一张相同的张数(包含自己)然后排序

 

 

#define RUN
#ifdef RUN

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <cctype> 
#include <algorithm>
#include <utility>
#include <math.h>
#include <ctime>

using namespace std;

#define MAXN 110

//输入序列
char numIn[11];	//牌的大小,标示值,如T,J,Q,K,A
int num[11];	//牌的大小,真实值
char suit[11];	//花色

int make[6];	//存放产生的二进制数

char name[10][MAXN] = {"highest-card","one-pair","two-pairs","three-of-a-kind","straight",
	"flush","full-house","four-of-a-kind","straight-flush"};

//手中牌的大小和花色
int Num[6];
int Suit[6];

int Win;

void printout(){
	for(int i=1; i<=10; i++){
		printf("%c%c ", numIn[i], suit[i]);
	}
	printf("\n");
	
	for(int i=1; i<=10; i++){
		printf("%d%c ", num[i], suit[i]);
	}
	printf("\n");
	printf("\n");
}

void printout2(){
	for(int i=1; i<=5; i++){
		printf("%d", make[i]);
	}
	printf("\n");
}

void printout3(){
	for(int i=1; i<=5; i++){
		printf("%d%c ", Num[i], Suit[i]);
	}
	printf("\n");
}

//判断牌大小和花色来确定什么牌
void play(){
	int win=0, shunzi=1, tonghua=1;
	int sum[6];	//存放重复的个数

	memset(sum, 0, sizeof(sum));

	//判断是否顺子
	for(int i=1; i<5; i++){
		if(Num[i]+1 != Num[i+1]){
			shunzi = 0;
			break;
		}
	}

	//顺子的特殊情况:(A,10,J,Q,K)
	if(Num[1]==1 && Num[2]==10 && Num[3]==11 && Num[4]==12 && Num[5]==13){
		shunzi = 1;
	}

	//判断是否同花
	for(int i=1; i<5; i++){
		if(Suit[i] != Suit[5]){
			tonghua = 0;
		}
	}

	//准备计算对子的数目
	//牌面大小为i共有sum[i]张
	for(int i=1; i<=5; i++){
		for(int j=1; j<=5; j++){
			if(Num[i] == Num[j]){
				sum[i]++;
			}
		}
	}

	//升序冒泡排序sum数组
	for(int i=1; i<5; i++){
		for(int j=i+1; j<=5; j++){
			if(sum[i] > sum[j]){
				int t = sum[i];
				sum[i] = sum[j];
				sum[j] = t;
			}
		}
	}

	//根据定义来确定最佳的牌面
	//对子 one-pair
	if(sum[5] == 2){
		win = 1;
	}

	//两对 two-pairs
	if(sum[2]+sum[3] == 4){
		win = 2;
	}

	//三条 three-of-a-kind
	if(sum[5] == 3){
		win = 3;
	}

	//顺子 straight
	if(shunzi){
		win = 4;
	}

	//五张同花 flush
	if(tonghua){
		win = 5;
	}

	//三条且一对 full-house
	if(sum[2]+sum[3] == 5){
		win = 6;
	}

	//4张同牌 four-of-a-kind
	if(sum[2] == 4){
		win = 7;
	}

	//同花顺 straight-flush
	if(tonghua+shunzi == 2){
		win = 8;
	}

	if(win > Win){
		Win = win;
	}
}

int main(){

#ifndef ONLINE_JUDGE
	freopen("131.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	
	while(scanf("%c%c", &numIn[1],&suit[1]) != EOF){
		for(int i=2; i<=10; i++){
			scanf(" %c%c", &numIn[i], &suit[i]);
		}
		getchar();
		
		Win = 0;

		//把牌值的T,J,Q,K,A转为数字,存入num
		for(int i=1; i<=10; i++){
			if(numIn[i] == 'T'){
				num[i] = 10;
			}
			else if(numIn[i] == 'J'){
				num[i] = 11;
			}
			else if(numIn[i] == 'Q'){
				num[i] = 12;
			}
			else if(numIn[i] == 'K'){
				num[i] = 13;
			}
			else if(numIn[i] == 'A'){
				num[i] = 1;
			}
			else if(isdigit(numIn[i])){
				num[i] = numIn[i] - '0';
			}
		}

		//printout();

		//产生5位二进制数的所有可能,从0到2^5-1
		for(int i=0; i<(1<<5); i++){
			int binDigit = 5;
			int tmp = i;
			memset(make, 0, sizeof(make));
			while(tmp != 0){
				make[binDigit] = tmp % 2;
				tmp /= 2;
				binDigit--;
			}

			//printout2();

			//根据产生的二进制序列来选择该丢弃哪一张牌,序列中0表示抛弃,1表示保留
			int dumpCnt = 0;
			int dump[6];
			memset(dump, 0, sizeof(dump));
			for(int i=1; i<=5; i++){
				if(make[i] == 0){
					dumpCnt++;
					//摸最顶端的牌来填补到前面被抛弃牌的位置
					Num[i] = num[5+dumpCnt];
					Suit[i] = suit[5+dumpCnt];
				}
				else{
					//没被抛弃的牌保持不变
					Num[i] = num[i];
					Suit[i] = suit[i];
				}
			}
			
			//printout3();

			//从小到大冒泡排序
			for(int i=1; i<5; i++){
				for(int j=i+1; j<=5; j++){
					if(Num[i] > Num[j]){
						int t1 = Num[i];
						Num[i] = Num[j];
						Num[j] = t1;
						char t2 = Suit[i];
						Suit[i] = Suit[j];
						Suit[j] = t2;
					}
				}
			}

			//printout3();

			play();

			


		}//End of generating binary

		

		printf("Hand: ");
		for(int i=1; i<=5; i++){
			printf("%c%c ", numIn[i], suit[i]);
		}

		printf("Deck: ");
		for(int i=6; i<=10; i++){
			printf("%c%c ", numIn[i], suit[i]);
		}

		printf("Best hand: %s\n", name[Win]);

	}

}


#endif

 

 

 

微信小程序 - 最新详细实现用户保存下载视频到手机相册,将视频临时路径、在线播放地址(网络路径)URL存储到手机,弹出访问手机相册权限询问,支持视频格式mp4、avi、mov、wmv、flv、webm 微信小程序,视频,手机相册,保存,另存为,小程序保存到相册权限,writePhotosAlbum,一键保存视频到手机相册功能(视频来源为链接),第一次要获取用户授权,授权使用相册权限,小程序视频下载,如何把视频下载到相册,下载一个视频到本地相册,显示下载进度,可取消下载,视频下载到本地,微信小程序视频如何下载,保存视频到相机,页面播放视频并下载到本地,安卓系统,苹果ios保存到相册报错,权限拒绝后打不开,添加相册授权弹框拒绝后再也出不来了,实现保存视频到手机相册功能,将mp4在线视频下载并存储到用户的手机中 阅读详情

相关推荐

保姆级教程:在NXPS32144环境下安装EB TRESOS 29.0.0并配置MCAL开发环境

本文提供了一份详细的保姆级教程,指导如何在NXP S32K144环境下安装EB TRESOS 29.0.0并配置MCAL开发环境。内容涵盖从前期资源准备、软件安装步骤、核心的MCAL关联配置,到首次创建AUTOSAR工程并进行模块配置的全流程,旨在帮助汽车电子开发者搭建稳定、可用的底层软件开发地基。

wind6的博客 955

当美女失去声音… 当美女失去声音…

净心编程 4365

网络可视化工具netron详细安装流程

netron安装目录1.netron 简介2.不同操作系统下的安装使用方式2.1 在线版本:只要有浏览器就可以2.2 不同操作系统安装使用3.netron支持的网络框架4.netron测试演示 1.netron 简介 在实际的项目中,经过会遇到各种网络模型,需要我们快速去了解网络结构。如果单纯的去看模型文件,脑海中很难直观的浮现网络的架构。 这时,就可以使用netron可视化工具,可以清晰的看到每一层的输入输出,网络总体的架构,而且支持各种不同网络框架,简单好用。 2.不同操作系统下的安装使用方式 2.1

江南研习社 12万+

python爬取美女图片

python爬取美女图片 字符串分割 截取 re模块使用 字符编码 decode encode 文件保存

Martin201609的博客 5万+

【React Native】源码分析之Native UI的封装和管理

转载请注明出处:http://blog.youkuaiyun.com/u013531824/article/details/54020287,谢谢。  ReactNative作为使用React开发Native应用的新框架,随着时间的增加,无论是社区还是个人对她的兴趣与日递增。此文目的是希望和大家一起欣赏一下ReactNative的部分源码。阅读源码好处多多,让攻城狮更溜的开发ReactNative应用的同时,也

Tiny的专栏 9778

五、2K0300 久久派开发板的GPIO控制与Shell脚本自动化实战

本文详细介绍了基于龙芯2K0300处理器的久久派开发板的GPIO控制方法,通过sysfs文件系统实现LED控制和传感器读取。重点讲解了Shell脚本自动化实战,包括LED闪烁、流水灯效果和传感器数据采集,为物联网项目开发提供完整解决方案。

silver的专栏 687

网络131第4周实验——键盘输入数据 和 数据类型(网络131 梁文俊)

1:程序练手。P21 例2-1 计算圆面积,在Eclipse中输入该程序的代码,得到运行结果。import java.util.Scanner; public class ComputeArea { public static void main (String args[]){ final double PI=3.14159; double area; //从键盘获取圆的半径值

提督的港湾 1375

如何打开本地网络的防火墙端口(Windows版)解决ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。问题

ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。 最开始在遇到这个报错的时候十分不解,后来经过思考,有可能是服务器端口占用,或者并没有放行。因此搜查问题的关键是要先去排查问题。 在搜索栏输入控制面板 选择防火墙 选择开关 保证这些选项是开着的 选择高级设置 新建规则 创建协议端口 选择端口 允许连接 点击下一步 创建规则后点击下一步(后命名) 选择任意端口ALL即可 问题排查完毕!socket创建网络通信时,有读者

weixin_46900108的博客 9万+

美女

美女 抖音“最美伴娘团”走红, 逆天颜值惊艳众人, 网友: 新娘更好看http://news.uc.cn/a_12619930700004822583/?from=UCPC http://image.uczzd.cn/16644087473349182928.jpg?id=0&from=export http://image.uczzd.cn/166440874...

weixin_30646315的博客 1645

便携式水下动态实时视频色彩还原设备,一键快速实现对水下偏色视频和图像的色彩还原处理

便携式水下动态实时视频色彩还原,一键快速对水下图像进行色彩校正,清晰度提升和亮度均衡处理,为水下资源勘探和科学考古,海洋生态环境监测,水下机器作业等应用提供有力的协助

weixin_43518680的博客 633

电脑蓝牙与ESP32蓝牙连接,让电脑发现ESP32

让PC发现ESP32蓝牙

injre! injre~ 5446

m,mm,mmm区别

Android源码目录下的build/envsetup.sh文件,描述编译的命令 m: Makes from the top of the tree. mm: Builds all of the modules in the current directory. mmm: Builds all of the modules in the supplied direc

zhonglunshun的专栏 2万+

Android 13.0仿ios的hotseat效果修改hotseat样式

在13.0系统产品rom定制化开发中,在项目需求的需要,系统原生Launcher的布局样式很一般,所以需要重新设计ui对布局样式做调整,产品在看到 ios的hotseat效果觉得特别美观,所以要仿ios一样不需要横屏铺满的效果 居中显示就行了,所以就要看hotseat的具体布局显示了

安卓兼职framework和app工程师的博客 1144

UVa 131 The Psychic Poker Player

本文介绍了一个扑克牌游戏问题,玩家初始获得5张手牌,可通过丢弃0-5张牌并用牌堆顶部的牌替换来优化牌型。题目假设玩家能预知牌堆顶部的5张牌。解题思路是枚举所有可能的换牌方案(共32种),并对每种方案评估牌型价值。关键点包括:换牌规则、枚举策略(暴力搜索)、牌型判断顺序(从同花顺到高牌共9种)。代码实现通过回溯法生成所有换牌组合,调用牌型判断函数确定最优解。该算法能高效找到最佳换牌策略,使最终手牌价值最大化。

寂静山林 688

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

uva-131 - The Psychic Poker Player

The Psychic Poker Player  In 5-card draw poker, a player is dealt a hand of five cards (which may be looked at). The player may then discard between zero and five of his or her cards and ha

写东西的地方 797

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

uva 131 The Psychic Poker Player

思路挺简单的,就是判断手牌的类型比较麻烦一点,核心思想是枚举手牌子集,然后把桌上的牌的上面的某几张牌和手牌子集中的牌凑足5张,所有的情况里面最优的组合就是最后的答案,注意子集为空集的时候的特殊情况。 #include #include #include struct node { int value; char color; }; bool operator > (struct

皓首不倦 不负少年 744

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

uva 131 - The Psychic Poker Player

参考题解  原题  子集生成的问题。用增量构造法。需要先弄清楚规则。特殊的顺子有两种,TJQKA和A2345。 #include #include #include using namespace std; const int maxn=15; char *sf="A23456789TJQK"; char *su="CDHS"; char str[9][20]={"straight-f

LeanCloud-lzwjava 969

UVA 131 The Psychic Poker Player

UVA 131 The Psychic Poker Player题目大意:手牌五张 排堆五张,超能力者可以看到这10张牌,可以弃掉x张牌摸x张牌,问能凑出的最大的牌 比较规则 比较规则如下:(按优先级排序)1.straight-flush:同花顺,牌面为T(10) - A2.four-of-a-kind:四条,牌面有4个相同的值;3.full-house:牌面有3个相同值,剩下2个也相同值;4.

ZeroLH00的博客 434

UVA131 HDU1629 The Psychic Poker Player【暴力】

The Psychic Poker Player Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 255 Accepted Submission(s): 49 Problem Description In 5-card draw p...

海岛Blog 725

UVa 131 - The Psychic Poker Player

一手牌(规则请见:http://dpk888.com/school/discussions/%E4%B8%80%E6%89%8B%E7%89%8C%E7%9A%84%E7%89%8C%E5%9E%8B-poker-hands#per_page=10),枚举 + 模拟,关键是明白其桌子上的牌相当于一个栈,只有丢掉手里相应数量的牌才可以从栈中依次抽出相应数量的牌来维持手里始终有五张牌,依此枚举。

GooMaple 725

UVA 131 The Psychic Poker Player

UVA-131题意:给出 5 张手牌和 5 张备用牌。可以任意丢弃手上的 k 张牌,并从备用牌上方抽 k 张补充。求手上能达到的最大牌面。 解题思路: 首先要搞清楚牌面的大小顺序。 同花顺(AKQJ10,花色相同就行)>四条(四张相同的牌,炸弹 = =) > 福尔豪斯 (aaabb的牌型) > 同花(5张花色相同) > 顺子 (连续,无视花色。A可以当1也可以当14)> 三条 (aaabc

QzNarsh的博客 621

UVA 131 - The Psychic Poker Player 暴力不解释

#include #include #include using namespace std; char t[][20] = {"straight-flush","four-of-a-kind","full-house","flush","straight" ,"three-of-a-kind","two-pairs","one-pair","highest-ca

泪无痕 741

uva 131 The Psychic Poker Player(直接枚举)

The Psychic Poker Player  In 5-card draw poker, a player is dealt a hand of five cards (which may be looked at). The player may then discard between zero and five of his or her cards an

不慌不忙、不急不躁 1832

uva131 The Psychic Poker Player

The Psychic Poker Player Time Limit: 3000MS     64bit IO Format: %lld & %llu Description In 5-card draw poker, a player is dealt a hand of five cards (which may be looked at)

keshuqi的博客 553
上一篇: IT民工的一些箴言
下一篇: adb pull and push
chiiis
博客等级 码龄14年 422粉丝 429原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值