HDU 1338 Game Prediction 贪心

【贪心】Game Prediction 题目  题目地址:Game Prediction思路  能想到应该每次都先出大的,但是对题目中所要求的至少赢的局数的最大值一脸懵逼。   既然是至少赢的局数,那么自然其他人在能赢的时候不会放水。所以从大到小遍历所有的牌,记录其他人手中有多少张比自己大的牌;当遇到一张自己的牌时,如果其他人手中没有比自己大的牌,那么肯定赢了一局,不然其他人就把比自己大的牌中最小的那张出了。代码// 思路:每次都出最大 阅读详情

Problem Description
Suppose there are M people, including you, playing a special card game. At the beginning, each player receives N cards. The pip of a card is a positive integer which is at most N*M. And there are no two cards with the same pip. During a round, each player chooses one card to compare with others. The player whose card with the biggest pip wins the round, and then the next round begins. After N rounds, when all the cards of each player have been chosen, the player who has won the most rounds is the winner of the game.
Given your cards received at the beginning, write a program to tell the maximal number of rounds that you may at least win during the whole game.
 

Input
The input consists of several test cases. The first line of each case contains two integers m (2 <= m <= 20) and n (1 <= n <= 50), representing the number of players and the number of cards each player receives at the beginning of the game, respectively. This followed by a line with n positive integers, representing the pips of cards you received at the beginning. Then a blank line follows to separate the cases.

The input is terminated by a line with two zeros.
 

Output
For each test case, output a line consisting of the test case number followed by the number of rounds you will at least win during the game.
 

Sample Input
  
2 5 1 7 2 10 9 6 11 62 63 54 66 65 61 57 56 50 53 48 0 0
 

Sample Output
  
Case 1: 2 Case 2: 4
 

Source
 


题目意思:

有m个人,每个人有n张牌,牌点为在1~n*m中的不同的数。每回合每个人出一张牌,点数最大的那个人赢,给出A人初始时的n张牌的牌点,问A至少赢的次数。


思路: 看做两个人单挑,你有m张牌,我有m*(n-1)张牌,每次我都出比你大大一点的牌,如果没有,出最小的m张牌(可以忽略),不用担心什么的


上代码了:


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 10005

int n,m;
int vis[N],a[N];

int main()
{
    int i,ca=0;
    while(~scanf("%d%d",&n,&m),n+m)
    {
        memset(vis,0,sizeof(vis));

        for(i=0;i<m;i++)
        {
            scanf("%d",&a[i]);
            vis[a[i]]=1;      //我手上没有的牌
        }

        int ans=0;
        sort(a,a+m);  //排序对方的牌

        int top; 
        
        for(i=m-1;i>=0;i--)  //这里for(i=0;i<m;i++) 也是一样正确的,不必纠结
        {
            for(top=a[i];;top++)
                if(!vis[top])
                 break;

            if(top<=n*m)
                vis[top]=1;  //出掉这张牌
            else
                ans++;    //没有比他大的,出最小牌(可以忽略出最小牌)
        }

        printf("Case %d: %d\n",++ca,ans);
    }
    return 0;
}


       










python特征选择pso_【来点干货】机器学习中常用的特征选择方法及非常详细的Python实例... 花费了很长时间整理编辑,转载请联系作者授权,违者必究。特征选择(Feature selection)是在构建预测模型的过程中减少输入变量的一个过程。它是机器学习中非常重要的一步并在很大程度上可以提高模型预测精度。这里我总结了一些机器学习中常见的比较有用的特征选择方法并附上相关python实现code。希望可以给大家一些启发。首先,我们为什么要进行特征选择呢?它有以下几个优点:减少过拟合:冗余数据常... 阅读详情

相关推荐

如何利用URDF文件表示并联结构(仅适用于支持SDF格式的仿真环境)

介绍了一种使用URDF文件在Gazebo中表示并联结构的方法,该方法使用了URDF的SDF拓展。在一个具有并联结构的双足机器人上应用并演示了此方法的有效性。

RobotFreak的博客 3847

Game Prediction(贪心)

Game Prediction(贪心) Suppose there are M people, including you, playing a special card game. At the beginning, each player receives N cards. The pip of a card is a positive integer which is at most N*M. And there are no two cards with the same pip. During a

Anthcony的博客 588

记一次springboot集成海康威视SDK过程

一开始没有接触过物联网这块,走了很多弯路,后面还是自己一点点摸索出来的。有个项目,需要对海康的门禁设备进行集成,后台统一管理设备,进行设备人脸数据的下发、删除等操作。3.我还接入了门禁设备的事件监听,门禁所有的事件都会上报到后台服务,这块代码有需要的可以找我。在linux系统中,sdk我使用的是绝对路径,把Linux版本的文件放到服务时,Acs文件夹下的 各个Manage都有现成的代码,可以根据自己的需要调用即可。路径也不要有中文,切记!2.sdk的存放路径不要有中文,不然会出现很多奇怪的问题。

huang_xiaoen的博客 2348

Game Prediction

Suppose there are M people, including you, playing a special card game. At the beginning, each player receives N cards. The pip of a card is a positive integer which is at most N*M. And there are no t...

Angeliaaa的博客 301

从DIY到实战:手把手教你搭建一个媲美吉时利2450的nA级电流源表(附原理图与避坑指南)

本文详细解析如何从零打造nA级精密电流源,涵盖核心设计原理、PCB布局技巧、热电偶效应应对及校准验证体系。通过低成本替代方案和优化设计,实现媲美商用源表的性能,特别适合硬件爱好者和独立开发者。文章还提供原理图与避坑指南,助你轻松搭建高精度电流源系统。

weixin_42656416的博客 291

ubuntu20.04 终端安装claude

【代码】ubuntu20.04 终端安装claude。

hongliyu_lvliyu的博客 2589

贪心题解 Game Prediction (田忌赛马问题)

suppose there are M people, including you, playing a special card game. At the beginning, each player receives N cards. The pip of a card is a positive integer which is at most N*M. And there are no two cards with the same pip. During a round, each player

R的博客 453

【TCAX相关】Python 官方手册下载页面(中文+英文)

Python 官方手册下载页面(中文+英文) 中文: https://docs.python.org/zh-cn/3.8/archives/ https://docs.python.org/zh-cn/3.6/archives/ 英文: https://www.python.org/doc/versions/ https://docs.python.org/3/archives/ https://www.python.org/ftp/python/doc/ ...

Seekladoom的博客 1012

贪心 hdu-1338-Game Prediction

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1338 题目意思: 有m个人,每个人有n张牌,牌点为在1~n*m中的不同的数。每回合每个人出一张牌,点数最大的那个人赢,给出A人初始时的n张牌的牌点,问A至少赢的次数。 解题思路: 其他人要想赢得最多,肯定赢A中牌点小的容易,而只要有一个人的牌点大于A牌点就行,此时可以把小牌都出掉。 所以

cc_again的专栏 1169

135、转动惯量辨识方法

<think>我们要求根据内容生成≤150字的文章摘要。内容是关于电机控制中转动惯量辨识的方法和工程经验。摘要需简洁概括核心:转动惯量重要性、三种方法(加减速法、正弦扫频、MRAS)、工程注意点(摩擦补偿、采样同步等)、实用建议(组合使用、滤波限幅、安全保护)。字数严格≤150。需要提炼。</think>转动惯量辨识是电机控制的关键,负载变化会导致速度环失稳。工程常用加减速法(简单可靠)、正弦扫频法(高精度)、MRAS在线辨识。实操需补偿摩擦、同步采样、控制激励幅度。建议混合使用,辨识结果需滤波限幅,并设置

2401_88858637的博客 39

『OPEN3D』1.2 mesh处理 python篇

介绍open3d对mesh的基本处理操作

NNNNNathan的博客 4648

POJ1323 LA2521 HDU1338 ZOJ1362 Game Prediction【贪心】

Game Prediction Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 12596 Accepted: 6053 Description Suppose there are M people, including you, playing a special card game. At the beginning, each player receives N cards. The pip of a card is a pos

海岛Blog 434

yolov26改进 | 融合改进篇 | 基于 MobileNetV4 和双向特征金字塔网络BiFPN的融合改进(全网独家首发)

本文介绍BiFPN与MobileNetV4融合改进的YOLOv26。许多模块单独使用能够涨点,但直接叠加后可能因功能重复、通道不匹配、尺度冲突而掉点,因此融合前必须理解各模块作用。MobileNetV4利用UIB与Mobile MQA构建轻量主干,提升特征提取能力;BiFPN通过可学习权重完成双向多尺度融合,强化大、中、小目标的信息交互。两者优化Backbone与Neck,功能互补、结构冲突较少。本文提供代码、配置、消融对比及Codex修改思路,MobileNetV4也可替换其他主干,便于组合实验与二次创新

Snu77的博客 239

HDU 1338 Game Prediction【贪心】

慧航空AI大赛”(报名中...)    Game Prediction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1613    Accepted Submission(s): 915 ...

小萨摩的博客 480

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

Statistics and Machine Learning Toolbox

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

【贪心+田忌赛马】HDU-1338 Game Prediction

注解 1、贪心。一共M个人,除了自己,可以把另外M-1个人当做1个人,对结论没有影响。 2、要找的是自己最少能赢多少场,也就是最多会输多少场。当自己手中最小的牌比剩下的人手中最小的牌还要小的时候,肯定会输。 3、对自己和其余的人的牌用Hash的方法存储。然后依次遍历剩余人手中的最小的牌,当自己手中有比这张牌还小的牌的时候,此轮必输。求出了必输的轮数,那么最少会获胜的次数就是N减去必输的轮数。 代...

zhanggirlzhangboy的博客 288

WINCC7.3破解文件

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

【贪心专题】POJ 1323 && HDU 1338 Game Prediction (贪心)

链接:click here~~ 题意: 有m个人,每个人有n张牌,牌点为在1~n*m中的不同的数。每回合每个人出一张牌,点数最大的那个人赢,给出A人初始时的n张牌的牌点,问A至少赢的次数。 【解题思路】 看做两个人互相出牌,注意出牌的顺序,你有m张牌,我有m*(n-1)张牌,每次我都出比你大一点的牌,如果没有,出最小的m张牌(可以忽略), 每次出最大的。如果别人手中最大的小于你的

herongwei 的 BLOG 1169

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

贪心策略 HDU - 1338 Game Prediction

Problem DescriptionSuppose there are M people, including you, playing a special card game. At the beginning, each player receives N cards. The pip of a card is a positive integer which is at most N*M....

笑彪夕的博客 806

hdu 1338 Game Prediction

题目地址:

心之所向,无惧无悔! 1097

HDU - 1338 Game Prediction

Game Prediction HDU - 1338 AYIT-2021 609暑假集训第一周 周赛题 Suppose there are M people, including you, playing a special card game. At the beginning, each player receives N cards. The pip of a card is a positive integer which is at most N*M. And there are no two

武幻空的博客 193

HDU 1338 Game Prediction

这题我用的是贪心算法,我的理解是这样的: 要求我最少能赢的次数,就是求别人最多能赢的次数。首先把我的牌先升序排序,然后我从小开始出,对于我出的牌,别人应该尽可能的压,而且用他们比我大的最小的那张牌;如果他们不压,那么他们后面这张牌就很有可能用不上,就少赢一次。 #include #include #include #include #include #include using namespa

最光阴的专栏 675

hdu 1338Game Prediction

Game Prediction Time Limit: 1000msMemory Limit: 32768KB This problem will be judged on HDU. Original ID: 1338 64-bit integer IO format: %I64d Java class name: Main Prev Submit Status Statistics

NITjianbagengmu的博客 345

POJ1323 Game Prediction (贪心)

Description Suppose there are M people, including you, playing a special card game. At the beginning, each player receives N cards. The pip of a card is a positive integer which is at most N*M. And t...

邵光亮的博客 772
上一篇: POJ 3087 Shuffle'm Up(模拟)
下一篇: CF 332 C 贪心
左眼皮跳跳~
博客等级 码龄13年 17粉丝 400原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值