D - 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 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?20) and n (1?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
这题只要比较其他人中有多少可以比他大的,他如果是最大的就不管他,跳过就好了,田忌赛马哈哈;
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<string.h>
#include<algorithm>
#define sf scanf
#define pf printf
#define cl clear()
#define pb push_back
#define mm(a,b) memset((a),(b),sizeof(a))
#include<vector>
const double pi=acos(-1.0);
typedef __int64 ll;
typedef long double ld;
const ll MOD=1e9+7;
using namespace std;
bool com(int a,int b)
{
return a>b;
}
int a[1005],d[1005];
int main()
{
vector<int> v;
int cas=1,m,n;
while(1)
{
v.cl;
sf("%d%d",&m,&n);
if(m==0)
return 0;
for(int i=0;i<n;i++)
sf("%d",&a[i]);
sort(a,a+n,com);
int i,j;
for( i=n*m,j=0;i>0;i--)
{
if(i!=a[j])
v.pb(i);
else
j++;
}
int ans=0;
for(i=0,j=0;i<n;)
{
if(a[i]>v[j])
i++;
else
{
ans++;
i++;
j++;
}
}
pf("Case %d: %d\n",cas++,n-ans);
}
}
D - Game Prediction的更多相关文章
- 论文阅读(Xiang Bai——【arXiv2016】Scene Text Detection via Holistic, Multi-Channel Prediction)
Xiang Bai--[arXiv2016]Scene Text Detection via Holistic, Multi-Channel Prediction 目录 作者和相关链接 方法概括 创新 ...
- scikit-learn使用笔记与sign prediction简单小结
经Edwin Chen的推荐,认识了scikit-learn这个非常强大的python机器学习工具包.这个帖子作为笔记.(其实都没有笔记的意义,因为他家文档做的太好了,不过还是为自己记记吧,为以后节省 ...
- 【转载】Chaotic Time-Series Prediction
原文地址:https://cn.mathworks.com/help/fuzzy/examples/chaotic-time-series-prediction.html?requestedDomai ...
- (转)LSTM NEURAL NETWORK FOR TIME SERIES PREDICTION
LSTM NEURAL NETWORK FOR TIME SERIES PREDICTION Wed 21st Dec 2016 Neural Networks these days are th ...
- 【软件分析与挖掘】Multiple kernel ensemble learning for software defect prediction
摘要: 利用软件中的历史缺陷数据来建立分类器,进行软件缺陷的检测. 多核学习(Multiple kernel learning):把历史缺陷数据映射到高维特征空间,使得数据能够更好地表达: 集成学习( ...
- FJNU 1155 Fat Brother’s prediction(胖哥的预言)
FJNU 1155 Fat Brother’s prediction(胖哥的预言) Time Limit: 1000MS Memory Limit: 257792K [Description] [ ...
- MATLAB时间序列预测Prediction of time series with NAR neural network
具体请参考:http://lab.fs.uni-lj.si/lasin/wp/IMIT_files/neural/nn05_narnet/ 神经网络预测时间序列数据,有三种模型, 这里是给出的是第二种 ...
- Kaggle Bike Sharing Demand Prediction – How I got in top 5 percentile of participants?
Kaggle Bike Sharing Demand Prediction – How I got in top 5 percentile of participants? Introduction ...
- Intra Luma Prediction
在宏块的帧内预测过程中,有四种宏块类型:I_4x4,I_8x8,I16x16,I_PCM.他们都需要在相邻块做去块滤波之前进行帧内预测. 亮度帧内预测的总体流程 1-4获取当前block的帧内预测模式 ...
- Intra Chroma Prediction
帧内预测依赖于当前宏块的相邻宏块,如果任何一个相邻宏块不可用,那么会直接影响到当前宏块的预测方式. 那么宏块怎么才谓之可用? 满足以下几个条件的相邻宏块为不可用: 相邻宏块超出边界,即(x<0 ...
随机推荐
- CentOS中环境变量和配置文件
什么是环境变量 bash shell用一个叫做 环境变量(environment variable) 的特性来存储有关shell会话和工作环境的信息.即允许在内存中存储数据,使得在程序或shell中运 ...
- MySQL中的insert ignore into, replace into用法总结
MySQL replace into 有三种形式: 1. replace into tbl_name(col_name, ...) values(...) 2. replace into tbl_na ...
- 11G新特性 -- ASM Fast Mirror Resync
ASM Fast Mirror Resync 在oracle 10g中,如果asm磁盘因为光纤.控制器发生故障而发生failure,asm将无法继续向该磁盘中写入数据. asm会将发生 ...
- c# 创建项目时提示:未能正确加载“microsoft.data.entity.design.bootstrappackage.。。。。
google了下, 果然找到办法了.看有的说要卸载,再清理注册表,真心不愿意啊,这安装一次就得好长时间.还好找到了这篇博文,无需卸载重安装,很简单的解决的方式,具体见http://blog.sina. ...
- Effective Java 第三版——56. 为所有已公开的API元素编写文档注释
Tips 书中的源代码地址:https://github.com/jbloch/effective-java-3e-source-code 注意,书中的有些代码里方法是基于Java 9 API中的,所 ...
- 设置tomcat 编译文件位置【转】
问题: 将项目发布到tomcat时,发现tomcat的cclasses目录下无任何编译后的文件. 解决方法:设置MyEclipse的文件编译目录即可: http://my.oschina.net/u/ ...
- [na][dhcp]dhcp细枝末节&dhcp防攻
回顾了下,真是以前是一种感觉以后是一种感觉. 特点: 1.dhcp服务器上的配置的网关不一定要有这个ip 2.dhcp服务只是个类似数据库而已(如果不在一个lan). 3. 如果dhcp不在一个lan ...
- Socket网络编程--小小网盘程序(4)
在这一小节中实现了文件的下载,具体的思路是根据用户的uid和用户提供的文件名filename联合两张表,取得md5唯一标识符,然后操作这个标识符对应的文件发送给客户端. 实现下载的小小网盘程序 cli ...
- ECMAScript 6 入门之新的数据类型Symbol
1.Symbol,一个每次创建都不一样的值 Symbol undefined null Boolean String Number Object let c=Symbol("这是一个Symb ...
- linux设置开机自启动
一..在/etc/rc.local文件中添加自启动命令 执行命令: 编辑"/etc/rc.local",添加你想开机运行的命令 运行程序脚本:然后在文件最后一行添加要执行程序的全路 ...