Game Prediction POJ
来源:互联网 发布:如何下载excel2010软件 编辑:程序博客网 时间:2024/06/06 06:30
// 大意就是输入 n, m,表示有 n 个人,每个人有 m 张牌,牌面从 1 到 m*n , 第二行输入 m 个数表示你自己手里有的牌和牌的大小
// 问利用你手里现有的这几张牌,你最多可以通过比大小稳赢多少次,你的比其他人的都大,你一定会赢
#include<stdio.h>#include<string.h>int main(){int a,b,num;int r = 1;while(scanf("%d %d",&a,&b) && (a||b)){int book[1100];int count = 0;int sum = 0;memset(book,0,sizeof(book));for(int i=0; i<b; i++){scanf("%d",&num);book[num] = 1;}for(int i=a*b; i>=1; i--){if(book[i]==0)// 从最大的开始按顺序比较sum++;// 如果这个数不是自己手里的就让别人手里的大牌数目加一 sum++ else// 如果这个牌是自己的 {if(sum == 0)// 如果别人手里没有比这个牌大的大牌,count++;// 一定赢的次数加一 count++elsesum--;// 否则别人就出一张大牌 sum--}}printf("Case %d: %d\n",r++,count);}}
阅读全文
0 0
- POJ 1323 Game Prediction
- poj 1323 Game Prediction
- poj 1323 Game Prediction
- POJ-1323-Game Prediction
- poj 1323 Game Prediction
- poj 1323 Game Prediction
- POJ 1323 Game Prediction
- poj Game Prediction
- poj 1323 Game Prediction
- POJ 1323 Game Prediction
- POJ-1323 Game Prediction
- poj----Game Prediction
- poj 1323 Game Prediction
- Game Prediction POJ
- POJ | 1323 Game Prediction | 贪心
- POJ 1323 Game Prediction 贪心
- POJ 1323 Game Prediction(贪心)
- POJ 1323 Game Prediction 题解
- std::getline从输入流中读取多行字符串
- HDU
- collect2.exe: error
- 推荐系统(1)——推荐系统概述
- HDU 1010Tempter of the Bone(dfs+剪枝)
- Game Prediction POJ
- codeforce 851 B Arpa and an exam about geometry(思路)
- 初识rabbitmq
- Junit4测试Service中的方法
- SIFT,SURF,ORB,FAST 特征提取算法比较
- LeetCode——104. Maximum Depth of Binary Tree
- 【CUGBACM15级BC第31场 B】hdu 5179 beautiful number
- 简历制作
- 提出一种数据结构支持push和pop操作以及第三种操作findMin,返回最小值,所有操作均以O(1)最坏时间运行