uva-131 - The Psychic Poker Player

YOLOv8改进 | 融合篇,YOLOv8改进主干网络为MobileNetV3+CA注意机制+添加小目标检测层(全网独家首发,实现极限涨点) 小目标检测难点众多,导致很多算法对小目标的检测效果远不如大中型目标。影响算法性能的主要原因如下:第一,小目标分辨率低、信息量不足,导致神经网络提取到的有效特征较少。第二,小目标在图像中所占的区域较小,易受背景干扰,这对算法的定位性能要求较高。第三,小物体标注困难,训练数据有限,导致模型泛化能力差。例如多尺度学习、无锚机制和生成对抗学习等方法,都能提高小目标检测的准确性和鲁棒性。为了改善小目标漏检现象严重的问题,我在 YOLOv8 中增加了 P2 检测头,相当于有四个检测头,使网络能检测到更小的目标。 阅读详情



 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


题意是给你手上五张牌,桌子上五张牌。你有一次机会可以舍弃手上任意k张牌,并从桌子上顶部开始拿k张牌,输出手上的牌和桌子上的牌和你能得到的最大组合

直接枚举一遍五张牌的状态然后舍弃和抽取,找出最大的组合。用5位二进制数表示五张牌的状态,1代表丢弃,0代表保留,用变量i从0-31表示总共32种状态

#include <iostream>
#include <algorithm>
using namespace std;

//枚举常量,按照牌的大小,从大到小
enum BestHand{straight_flushs,four_of_a_kind,full_house,flushs,straight,
        three_of_a_kind, two_pairs, one_pair};

string str[8] = {"straight-flush","four-of-a-kind","full-house","flush","straight",
        "three-of-a-kind", "two-pairs", "one-pair"};


struct c   //每张牌的数据,数值大小和花色
{
    int value;
    char suit;
};

int getValue(char ch) //牌的大小2-A,转换成由数字1-13表示,便于比较和排序
{
    switch(ch){
    case 'A':
        return 13;
    case 'T':
        return 9;
    case 'J':
        return 10;
    case 'Q':
        return 11;
    case 'K':
        return 12;
    default:
        return 1+ch-'2';
    }
}

c deck[5];
c hand[5];
c cp[5];

int cmp(const c & a, const c &b) //牌的排序方式,用作sort函数的参数
{
    return a.value < b.value;
}

//牌判断前都是按大小从小到大排好序了

int isSAF()     //判断,同花、顺子、同花顺
{
    int s = 1, f = 1;  //s(straight)代表是否顺子,f(flush)代表同花

    //判断是否为顺子,因A代表的是13,所以第二个条件是对于A 2 3 4 5特判
    for(int i = 0; i < 4; i++)
     if(cp[i+1].value - cp[i].value != 1 && !(i==3 && cp[i].value==4 && cp[i+1].value == 13)){
        s = 0;
        break;
    }

    for(int i = 1; i < 5; i++)
    if(cp[i].suit != cp[0].suit){
        f = 0;
        break;
    }

    if(s && f)
        return straight_flushs;
    else if(f)
        return flushs;
    else if(s)
        return straight;
    else
        return 100; //什么都没有返回一个不可能的值,取大的



}

int isFAK() //判断炸
{
    for(int i = 1; i < 4; i++){
        if(cp[i].value != cp[0].value)
            break;
        if(i == 3) return four_of_a_kind;
    }

    for(int i = 3; i >= 1; i--){
        if(cp[i].value != cp[4].value)
            break;
        if(i == 1) return four_of_a_kind;
    }

    return 100;
}


int isTTO()//判断葫芦,三条,两对,一对
{
    int three = 0, pairs = 0;

    for(int i = 0; i < 3; i++)
        if(cp[i].value == cp[i+1].value && cp[i+1].value == cp[i+2].value)
            three = 1;
    //判断对的时候注意如果是三条就不能算对了
    for(int i = 0; i < 4; i++)
        if(cp[i].value == cp[i+1].value && cp[i+1].value != cp[i+2].value && (!i || (cp[i-1].value != cp[i].value)))
        pairs++;

    if(three && pairs)
        return full_house;
    else if(three)
        return three_of_a_kind;
    else if(pairs == 2)
        return two_pairs;
    else if(pairs)
        return one_pair;
    else
        return 100;

}



int main()
{
    char a, b;
    while(cin >> a >> b){
    cout << "Hand: ";
    for(int i = 0; i < 5; i++){
            if(i)
            cin >> a >> b;
            hand[i].value = getValue(a);
            hand[i].suit = b;
            cout << a << b << " ";
    }

    cout << "Deck: ";
    for(int i = 0; i < 5; i++){
            cin >> a >> b;
            deck[i].value = getValue(a);
            deck[i].suit = b;
            cout << a << b << " ";
    }

    int ans = 100;
    cout << "Best hand: ";
    for(int i = 0; i < 32; i++){ //用5个二进制数表示手上牌的状态,1代表丢弃换牌,0表示不换
        int used = 0;   //表示换了多少张牌,从左边开始换(也就deck上的top)
        for(int j = 0; j < 5; j++) cp[j] = hand[j];
        for(int t = 0; t < 5; t++){
            if((i>>t)&1) cp[t] = deck[used++];
        }

        sort(cp, cp+5, cmp); //将牌从小排到大

        ans = min(ans, isSAF());
        ans = min(ans, isFAK());
        ans = min(ans, isTTO());
    }



    if(ans == 100) //什么都没有输出highest-card
        cout <<"highest-card\n";
    else
        cout << str[ans] << endl;
    }
    return 0;
}


【React】1、React入门与概览(JSX语法) React入门 文章目录React入门一、React全家桶1. React是什么?2. 谁开发的?3. 为什么要学?4. React的特点5. 学习React之前要掌握的JavaScript基础知识二、React 概览组件JSXVirtual DOM关于虚拟DOM:Data Flow三、React基本使用相关js库四、React JSXJSX 语法规则五、模块与组件、模块化与组件化的理解5.1 模块5.2 组件5.4 模块化5.5 组件化 一、React全家桶 React基础 React-Router(R 阅读详情

相关推荐

飞腾E2000单板移植openEuler 5.10内核与麒麟系统的实践指南

本文详细介绍了在飞腾E2000单板上移植openEuler 5.10内核并搭配麒麟系统根文件系统的完整实践指南。内容涵盖从编译环境搭建、内核配置裁剪、设备树适配,到根文件系统准备、U-Boot引导配置及启动调试的全流程,旨在帮助开发者打造一个内核版本新、软件生态全的稳定混合系统。

weixin_29309475的博客 269

UVaOJ131---The Psychic Poker Player

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 may then discard between zero and five

c随遇er安的专栏 703

Android蓝牙Mesh组网实战:从零搭建智能灯光控制系统(附完整代码)

本文详细介绍了基于Android平台开发蓝牙Mesh智能灯光控制系统的完整实战流程。从环境搭建、核心概念解析,到设备扫描配网、网络初始化、模型配置与消息通信,提供了完整的代码实现和调试技巧。重点讲解了如何使用开源Mesh库实现设备发现、分组控制、场景管理等核心功能,并分享了实际项目中遇到的典型问题与解决方案。

weixin_29174013的博客 672

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

小G的ACM之路 1086

IEC104协议下的文件传输与软件升级的技术细节与操作流程

本文深入探讨IEC104协议下的文件传输过程和软件升级机制,揭示其背后的技术细节和操作流程。

2401_86189088的博客 2533

深度篇——图像处理的一些方法(一) 关于 图像处理的三个层次 与 selective search

返回主目录 返回 图像处理的一些方法 目录 下一章:深度篇——图像处理的一些方法(二)细说性能评估 IOU和 GIOU 目录内容 深度篇——图像处理的一些方法(一)关于图像处理的三个层次 与 selective search 深度篇——图像处理的一些方法(二)细说性能评估 IOU和 GIOU 深度篇——图像处理的一些方法(三)细说 HOG特征与bag-o...

天下所弃,不过其纪。世间事,在人,在志。 2923

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

Cursor AI编程工具保姆级安装指南:从下载到中文界面设置(含免费额度说明)

本文提供Cursor AI编程工具的保姆级安装与设置教程。详细指导从官网下载、安装到中文界面切换的每一步,并重点说明其每月500次高级模型调用的免费额度策略。通过个性化设置与核心插件推荐,帮助开发者快速上手,提升AI辅助编程效率。

weixin_29191761的博客 680

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

题目:131 - The Psychic Poker Player 题目大意:刚开始我一点都不懂题目要我们做什么,后来看了别人的题解,发现原来是打某种类型的纸牌,手上有5张牌,桌上也五张牌,这个人可艺从手中丢弃某些牌,从轴上摸去相等数量的牌,桌上的牌是有顺序的,然后问手上最好的牌是什么。 解题思路:直接枚举丢牌和摸牌的情况,一共有2的5次方种,这里我用了位运算,用一个数来代替舍

801

SmartFusion从FPGA到ARM(八)——CoreUARTapb的使用

文章目录1.CoreUARTapb简介2.添加CoreAPB3总线IP核3.添加CoreUARTapb4.驱动代码实现5.库函数简介6.串口printf函数实现7.串口接收轮询和中断方式 系列教程:SmartFusion从FPGA到ARM系列教程 1.CoreUARTapb简介 对于SmartFusion2来说,MSS_UART的管脚可以任意分配,但是对于SmartFusion来说,MSS_UART的管脚是固定的不能分配: 109-UART0_RX 110-UART0_TX 111-UART1_RXD 11

whik1194的博客 2458

R语言实战应用精讲50篇(二)-多重线性回归系列之稳健回归

前言 线性回归的参数估计主要采用的是最小二乘法(又称最小平方法),该法是将使观测值与模型预测值之差的平方达到最小的值作为参数估计值。如果数据存在异常点或者异方差,最小二乘法估计会存在偏差,常用的处理策略就是改用稳健回归(Robust Regression)。 稳健回归就是采用更为稳健的参数估计方法来拟合模型,所谓稳健就是数据的波动对参数估计影响不大,比如不受异常值影响,或删除某一观测后对结果影响不大。稳健估计的方法有很多,主要有这么几类:最小绝对值回归(也称最小一乘法回归,lAV),最小中位数二乘法(L

wenyusuran的专栏 3162

UVa 131 The Psychic Poker Player

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

寂静山林 690

16、Arduino MEGA 2560 固件与电路详解

本文详细介绍了Arduino MEGA 2560的固件编程与电路设计,涵盖ATmega16U2和ATmega2560的熔丝配置、stk500v2引导加载程序的备份与恢复方法、使用Microchip Studio通过ICSP烧录固件的步骤,以及debugWIRE和JTAG调试接口的选择与配置。同时提供了电路块图解析、组件位置参考及常见问题解决方案,帮助用户深入理解硬件结构并进行高效开发与调试。

swift5iosmith的博客 200

uva 131 The Psychic Poker Player

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

皓首不倦 不负少年 744

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

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 970

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

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的博客 436

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

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

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

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

QzNarsh的博客 625

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

不慌不忙、不急不躁 1833

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

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
上一篇: kmp求字符串最小周期
下一篇: uva-110-Meta-Loopless Sorts
HuanTongH
博客等级 码龄12年 7粉丝 110原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值