TOJ 1117. Game Prediction
来源:互联网 发布:tensorflow网络微调 编辑:程序博客网 时间:2024/06/05 21:53
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 51 7 2 10 96 1162 63 54 66 65 61 57 56 50 53 480 0
Sample Output
Case 1: 2Case 2: 4
#include<iostream>#include<cstring>#include<algorithm>using namespace std;bool a[1000];int m,n;int f(int x){int i;for(i=x+1;i<=m*n;i++){if(!a[i]){a[i]=1;return 0;}}return 1;}int main(){int k=1,b[50],c;while(cin>>m>>n&&m&&n){memset(a,0,sizeof(a));for(int i=0;i<n;i++){cin>>b[i];a[b[i]]=1;}//for(int i=0;i<=m*n;i++)//cout<<a[i]<<" ";//cout<<endl;sort(a,a+n);c=0;for(int i=n-1;i>=0;i--){if(f(b[i]))c++;}cout<<"Case "<<k<<": "<<c<<endl;k++;}return 0;}
- TOJ 1117. Game Prediction
- Game Prediction
- Game Prediction
- Game Prediction
- Game Prediction
- Game Prediction
- Game Prediction
- pku1323 Game Prediction
- FZU 1113 Game Prediction
- POJ 1323 Game Prediction
- 1323 Game Prediction
- ZOJ 1362 Game Prediction
- poj 1323 Game Prediction
- poj1323(Game Prediction)
- poj 1323 Game Prediction
- poj1323 Game Prediction 贪心
- POJ-1323-Game Prediction
- poj 1323 Game Prediction
- 数据结构学习笔记:二叉树
- C#的假死问题
- 学生信息管理系统——整体构思
- nyist oj 58 最少步数(dfs搜索)
- 【POJ】3204 Ikki's Story I - Road Reconstruction 最大流
- TOJ 1117. Game Prediction
- java之多态的理解
- Android中的GridView详解
- hdu4635 有向图最多添加多少边使图仍非强连通
- Css-TH,TR,TD
- C#调用ORCLe 带参数select存储过程--10g及以下
- Qt实现3D纹理渲染自由旋转空间立方体
- hdu 1074 Doing Homework (状态压缩dp)
- 冒泡排序实现--python