UVA - 131 The Psychic Poker Player (暴力枚举+模拟)

YOLOv11半监督学习深度解析:基于FixMatch改进的先进目标检测框架 本文探讨了半监督学习与YOLOv11结合的创新方法。针对目标检测中半监督学习面临的伪标签质量不稳定、特征一致性难保证等挑战,研究提出改进版FixMatch框架。通过分析YOLOv11架构特性(如多尺度特征提取、双标签分配策略等)与半监督学习的适配性,设计了三项关键技术改进:空间感知阈值策略、多任务解耦处理和记忆增强机制。该方法在少量标注数据下可实现接近全监督的性能,显著降低工业检测等场景的数据标注成本。 阅读详情

 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


题目大意:
一道恶心的题目。
你有5张手牌,可以舍弃任意张,然后从桌上抽牌,注意只能一次。
这时候,你突然牛逼了,你可以洞察桌上从上到下放的都是什么牌。
输入你手上的5张牌和桌面最上方的5张牌。
输出你可以拿到的最强的组合。

德州扑克规则:

straight-flush,5张牌花色相同,点数递增1。(8分)
four-of-a-kind,5张牌有4张牌点数相同。(7分)
full-house,5张牌有3张牌点数相同,而且另外2张点数也相同。(6分)
straight,5张牌点数递增1,但是花色不同。(5分)
flush,5张牌花色相同,但是点数没有递增1。(4分)
three-of-a-kind,5张牌有3张点数相同,另外2张点数不同。 4 前3个相同后两个不同,前两个不同,后三个相同。(3分)
two-pairs,5张牌有两对牌点数相同。(2分)
one-pair,5张牌有一对牌点数相同。(1分)
highest-card,木有符合上面任何条件。(0分)

分数越高牌越好
这题没有什么捷径每种情况都要判断,只要有耐心就能AC。

注意:枚举全所有的组合时可以用2进制代替,如果有不懂请看下面的代码。


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
const int INF = 0x3f3f3f;
int map[255];
//将字符,转化为具体数字
void init() {
	map['A'] = 1; map['2'] = 2;
	map['3'] = 3; map['4'] = 4;
	map['5'] = 5; map['6'] = 6;
	map['7'] = 7; map['8'] = 8;
	map['9'] = 9; map['T'] = 10;
	map['J'] = 11;map['Q'] = 12;
	map['K'] = 13;
}

//保存每种可能
const char result[10][30] = {
	"highest-card",
	"one-pair",
	"two-pairs",
	"three-of-a-kind",	
	"straight",
	"flush",
	"full-house",
	"four-of-a-kind",
	"straight-flush"
};

struct Card{
	char suit; //保存每种花色
	int val; //保存每张牌的值
}card[10];

//顺子
bool flush( int val[]) {	
	if(val[0] == 1 && val[1] == 10 && val[2] == 11 && val[3] == 12 && val[4] == 13) {
		return true;
	}
	for(int i = 0; i < 4; i++) {
		if(val[i+1] - val[i] != 1) {
			return false;
		}
	}
	return true;
}

//同花
bool straight(int suit[]) {
	
	for(int i = 0; i < 4; i++) {
		if(suit[i] != suit[i+1] ) {
			return false;
		}
	}
	return true;
}

//炸弹
bool four(int val[]) {
	if( val[0] == val[1] && val[1] == val[2] && val[2] == val[3]) {
		return true;
	}
	if( val[1] == val[2] && val[2] == val[3] && val[3] == val[4]) {
		return true;
	}
	return false;
}

//三代二
bool house(int val[]) {
	if(val[0] == val[1] && val[1] == val[2] && val[3] == val[4]) {
		return true;
	}
	if(val[0] == val[1] && val[2] == val[3] && val[3] == val[4]) {
		return true;
	}
	return false;
}

//三相同
bool three(int val[]) {
	if(val[0] == val[1] && val[1] == val[2]) {
		return true;
	}
	if(val[1] == val[2] && val[2] == val[3]) {
		return true;
	}
	if(val[2] == val[3] && val[3] == val[4]) {
		return true;
	}
	return false;
}

//两对
bool two(int val[]) {
	if(val[0] == val[1] && val[2] == val[3]) {
		return true;
	}
	if(val[1] == val[2] && val[3] == val[4]) {
		return true;
	}
	if(val[0] == val[1] && val[3] == val[4]) {
		return true;
	}
	return false;
}

//一对
bool one(int val[]) {
	for(int i = 0; i < 4; i++) {
		for(int j = i+1; j < 5; j++) {
			if(val[i] == val[j]) {
				return true;
			}
		}
	}
	return false;
}

int solve(int A[]) {
	int val[5];
	for(int i = 0; i < 5; i++) {
		val[i] = card[A[i]].val;
	}
	sort(val,val+5);
	int suit[5];
	for(int i = 0; i < 5; i++) {
		suit[i] = card[A[i]].suit;
	}
	if( flush(val) && straight(suit)) {
			return 8;
	}else if( four(val)){
		return 7;
	}else if( house(val)) {
		return 6;
	}else if( straight(suit)) { //注意:同花比顺子大
		return 5;
	}else if( flush(val)) {
		return 4; 
	}else if( three(val)) {
		return 3;
	}else if( two(val)) {
		return 2;
	}else if( one(val)) {
		return 1;
	}
	return 0;
}
int main() {
	int sum,maxa;
	char str[10][3];
	init();
	while( scanf("%s",&str[0]) != EOF) {
		card[0].val = map[str[0][0]];
		card[0].suit = str[0][1];
		for(int i = 1; i < 10; i++) {
			scanf("%s",&str[i]);
			card[i].val = map[str[i][0]];
			card[i].suit = str[i][1];
		}
		//input
		int bit[5];
		int A[5];
		int t,p;
		maxa = -INF;
		for(bit[0] = 0; bit[0] <= 1; bit[0]++) {
			for(bit[1] = 0; bit[1] <= 1; bit[1]++) {
				for(bit[2] = 0; bit[2] <= 1; bit[2]++) {
					for(bit[3] = 0; bit[3] <= 1; bit[3]++) {
						for(bit[4] = 0; bit[4] <= 1; bit[4]++) {
							p = 0; 
							for(int i = 0; i < 5; i++) {
								if(bit[i])
									A[p++] = i;
							}
							t = p;
							for(int i = 5; i < 10-t; i++) {
								A[p++] = i;
							}
							sum = solve(A);
							maxa = max(maxa,sum);
						}
					}
				}
			}
		}
		//Print
		printf("Hand: ");
		for(int i = 0; i < 5; i++) {
			printf("%s ",str[i]);
		}
		printf("Deck: ");
		for(int i = 5; i < 10; i++) {
			printf("%s ",str[i]);
		}
		printf("Best hand: ");
		printf("%s\n",result[maxa]);
	}
	return 0;
}


Cesium 实现动态加载气象数据:渲染成动态雨雪/云层效果(源码 + 原理) 本文介绍了在Cesium中实现动态天气效果的技术方案。核心思路是通过时间轴驱动多层数据动态切换,包括:1)时间维度处理,按序列加载不同气象图层;2)空间维度处理,将气象数据切分为瓦片;3)效果层实现,制作风场、降水等动态可视化效果。文章详细讲解了后端数据预处理(生成瓦片和风场JSON)、前端实现(双层雷达瓦片交替渐变、风场粒子系统)的具体方法,并提供了完整的代码示例。此外还探讨了雨雪粒子、云层效果等增强功能,以及工程化建议,为构建科学准确的动态天气可视化系统提供了实用解决方案。 阅读详情

相关推荐

某知名系统漏洞挖掘与利用思路探索

本文以安全研究为目的,分享对该套系统的代码审计和漏洞挖掘过程,文中所提到的漏洞均已提交给CNVD&CITIVD,请勿用做非法用途。

C20220511的博客 1910

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

ARTIX-7 GTP 3G-SDI 工程构建与调试实战

本文详细介绍了基于ARTIX-7 FPGA和GTP收发器的3G-SDI工程构建与调试实战。从基础概念解析到Vivado工程创建、GTP IP核配置、SDI IP核集成,再到系统集成与时钟域处理,提供了全面的技术指导。文章还分享了调试技巧、常见问题排查方法以及性能验证步骤,帮助开发者快速掌握3G-SDI视频传输技术的实现与优化。

weixin_30443813的博客 260

uvaoj131 The Psychic Poker Player------醉人

uvaoj 131                   131 - The Psychic Poker Player Time limit: 3.000 seconds In 5-card draw poker, a player is dealt a hand of five cards (which may be looked at). The player

sinat_AQ的博客 594

ROS基础(一)——命令行代码(以小乌龟程序为例)

ROS学习(一)——命令行代码(以小乌龟程序为例)1 基础命令行语句1.1 roscore1.2 rqt_graph(显示系统计算图)1.3 rosnode(显示所有节点相关信息)1.4 rostopic(和话题相关)2 服务类型指令rosservice同时存在两只海龟3 指令记录 1 基础命令行语句 从大二四旋翼无人机编队后就没再接触过ROS了,最近由于科研任务需要重新捡起来,打算系统学一下!学习过程参考古月居老师的视频,有兴趣的同学可以去[BliBli]学习。 学习平台:Ubuntu 18.04 硬件

北理自动化小白 6275

从逻辑门到存储阵列:NAND与NOR闪存命名与结构原理详解

在数字电路与半导体存储器领域,逻辑门是构建一切复杂功能的基础单元,其输入输出关系定义了计算与存储的基本原理。与非门(NAND)和或非门(NOR)作为通用逻辑门,其真值表和行为模式深刻影响了芯片设计。基于这些原理,现代闪存技术发展出了两种核心架构:NAND Flash和NOR Flash。这两种闪存的命名直接源于其内部存储单元阵列的连接方式,分别模拟了与非门和或非门的逻辑关系。这种结构差异决定了它们根本的技术价值:NOR Flash采用并联结构,支持快速随机读取,适用于代码存储与原地执行(XiP);而NAND

weixin_33377602的博客 363

The Psychic Poker Player UVA131

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...

473687880 301

从立创商城到Cadence:手把手教你实现封装格式的精准迁移

本文详细介绍了如何从立创商城获取元器件封装并精准迁移至Cadence Allegro的全流程。通过实战案例MAX31865ATP+T芯片,逐步解析Altium Designer格式转换、Cadence环境配置、封装导入验证等关键步骤,提供常见问题解决方案和效率提升技巧,帮助硬件工程师实现封装格式的高效迁移。

weixin_42519985的博客 224

UVA 131:有超能力的纸牌玩家

难点:题意的理解 其实就是德州扑克的玩法。抽5张牌,然后留5张在桌面,可以选择丢弃1张牌,然后从桌面抽1张,从桌面抽的不能丢弃。最多丢弃五张牌,也就是把桌上留着的5张牌全拿上。 5张牌的大小比较: 1.straight-flush:同花顺。牌面为T(10) - A,这里不论花色是否同样; 2.four-of-a-kind:四条,牌面有4个同样的值。 3.full-house:船牌,牌面有...

qq_35752161的博客 422

目标检测YOLO实战应用案例100讲-基于YOLOv7的番茄采摘机械手场景感知及试验(下)

根据软件系统的设计需求,制定系统的可行性方案分析,编写系统的相关程序和 调试运行环境,对系统进行测试,以实现对番茄数据的采集及监测。登陆界面登陆后,进入选择界面,菜单包括了对番茄种植棚室的固定相机数据的监测、 对番茄采摘机械手的双目相机采集的番茄的静态、动态数据的获取、对番茄静态、动态数 据处理的功能菜单等选项。与利用人工去进行对于番茄果实的识别和数目的统计相比,番茄视觉系统自动记录番 茄数量以及红色已经成熟的番茄、青色未成熟番茄的数量,减轻人工记录的工作量,减少 人工记录的误差,从经济方面是可行的。

qq_36130719的博客 818

60、基于综合奖励的股票交易深度强化学习方法

本文提出了一种基于综合奖励的股票交易深度强化学习方法,通过结合TCN和Transformer构建策略网络,利用PPO和TRPO优化算法,设计综合考虑短期和长期收益的奖励函数,并引入基于BERT的情绪分析来减少数据噪声。实验结果表明,该方法在S&P500数据集上表现优异,能够有效降低风险并提高投资回报,具有良好的应用前景。

grpc6streamer的博客 80

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

写东西的地方 798

人工智能在文学领域的应用:创作无限可能的智能作家

人工智能在文学领域的应用:创作无限可能的智能作家 作者:禅与计算机程序设计艺术 1. 背景介绍 人工智能技术近年来飞速发展,在各个领域都有广泛应用。文学创作作为人类最高级的智力活动之一,也逐渐受到人工智能技术的影响和改变。随着自然语言处理、生成式模型等人工智能

AI天才研究院 1113

UVa 131 The Psychic Poker Player

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

寂静山林 690

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

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

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

uva 131 The Psychic Poker Player(暴力枚举+德州扑克)

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

总有那么一群人喜欢盯着我的博客看,估计这是他们见过最长的博客名,我必须得告诉他们博客名最长可以写多长 1891

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

uva 131 - The Psychic Poker Player

题目大意:就是德州扑克的题目。。。。 现在手上有5张牌,另外桌上还有五张牌,只能一次顶端取,现在问这个人通过舍弃手上的某些牌来获得牌的价值最大。。。 赤裸裸的暴力搜索 + 子集枚举  若加上一个最优化剪枝时间可以达到0.001秒。。。或许是我想多了。。 剪枝:就是判断当前牌的最大价值时,与已经得到的最大价值比较max,只需要判断当前的牌的价值能否大于max,如果没有大于max的下面

最爱她! 380

UVA 131 - The Psychic Poker Player

连接是:http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=67 又是暴力流的一个题目。 View Code 1 #include <iostream> 2 #include <algorithm> 3 using na...

weixin_30505485的博客 80

UVa OJ 题解索引

寂静山林 790

UVa 131 The Psychic Poker Player (枚举&模拟好题)

131 - The Psychic Poker Player Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;category=107&amp;page=show_problem&amp;problem=67 In 5-card...

844604778 208

uva 131 -The Psychic Poker Player(德州扑克)

G - The Psychic Poker Player Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Appoint description:  System Crawler  (2013-05-30) Description

NiaNiaJR的专栏 1667

UVA - 11059 Maximum Product (简单枚举)

Problem D - Maximum Product Time Limit: 1 second Given a sequence of integers S = {S1, S2, ..., Sn}, you should determine what is the value of the maximum positive product involving consecutive term

小G的ACM之路 1529

CodeForces - 63C Bulls and Cows(暴力求解)

Bulls and Cows Time Limit: 2000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Description The "Bulls and Cows" game needs two people to play. The thinker thi

小G的ACM之路 1346

UVA - 11218 KTV(暴力求解)

Problem K KTV One song is extremely popular recently, so you and your friends decided to sing it in KTV. The song has 3 characters, so exactly 3 people should sing together each time (yes, there

小G的ACM之路 1242

hdu 5374 Tetris(模拟俄罗斯方块)

题意: 俄罗斯方块想必大家都玩过,现在题目给出了3种俄罗斯方块。 O形,I形,L形 以及5种操作,w选择,a左移一位,d右移以为,w下移一位,p什么都不做。然后又给出了方块出现的序列,要求按所给出的操作能消除多少行。 解析: DRAW数组表示已(x,y)(x,y)为左下角,能在图上画出的形状。 然后模拟每个每个方块,直到当前方块不能动位置,在二维数组中标记方块,然后接下来选

小G的ACM之路 1199

HDU 5175 Misaki's Kiss again(暴力枚举+异或运算)

题意 找到满足gcd(N,M)==NxorM的M值(1<=M<=N) 解析: 令M = N xor K,原式:gcd(N,N xor K) == N xor (N xor K) == K 由此我们可以发现K是N的约数,找到所有N的约数,判断是不是满足那个等式即可,因为是异或运算,结果可能比约数本身大,如1xor2==3,还有异或出来结果等于0的舍掉,gcd(n,n) != n xor

小G的ACM之路 1127
上一篇: 子集生成的两种方法 (增量构造法 和 位向量法)
下一篇: UVA - 146 ID Codes (枚举排列)
HelloWorld10086
博客等级 码龄12年 88粉丝 614原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值