【POJ1323】Game Prediction 博弈,或者说贪心(本博客用栈处理)
来源:互联网 发布:xp关闭80端口 编辑:程序博客网 时间:2024/04/30 11:41
题意:
输入m,n,表示有若干张卡牌,权值两两不同,且最大为m*n,交给至多m个人。
每回合所有人各出一张牌,权值最大者胜!
现在主角手里有n张牌,问他至少能赢多少局。
题解:
贪心。每次出最大牌看是否可以有人压制你。
或者换一种说法,就是所有人一起坑你,而且提前知道了你出什么牌,总之就是各种坑你!所以我们不考虑能赢多少把,我们考虑有多少把会输!再转换一下就是看多少张牌必赢,怎么针对都没用!
实现:不存东西的栈。没看懂就看代码。。。水水的~
#include <cstdio>#include <cstring>#include <algorithm>#define N 10000using namespace std;int n,m,top,ans;bool visit[N];int main(){//freopen("test.in","r",stdin);int i,j,k,t=0;while(scanf("%d%d",&m,&n),m&&n){printf("Case %d: ",++t);m*=n;ans=top=0;memset(visit,0,sizeof(visit));for(i=1;i<=n;i++){scanf("%d",&k);visit[k]=1;}for(i=m;i;i--){if(visit[i]){if(top)top--;else ans++;}else top++;}printf("%d\n",ans);}return 0;}
1 0
- 【POJ1323】Game Prediction 博弈,或者说贪心(本博客用栈处理)
- POJ1323 Game Prediction(贪心)
- POJ1323 Game Prediction(贪心)
- poj1323 Game Prediction 贪心
- POJ1323 Game Prediction(贪心)
- POJ1323 Game Prediction(贪心算法训练)
- poj1323(Game Prediction)
- POJ1323 Game Prediction
- POJ1323------Game Prediction
- poj1323 Game Prediction
- Game Prediction(贪心)
- Game Prediction(贪心)
- POJ 1323-Game Prediction(贪心)
- poj Game Prediction 1323 (贪心ordp)
- 【贪心】Game Prediction
- 【贪心专题】POJ 1323 && HDU 1338 Game Prediction (贪心)
- POJ | 1323 Game Prediction | 贪心
- 贪心 hdu-1338-Game Prediction
- mysql 查询 行号
- 信息检索(IR)的评价指标介绍 - 准确率、召回率、F1、mAP、ROC、AUC<转>
- 深入理解openwrt架构(一)--安装准备和目录分析
- java教程(四)关于MVC
- APK 静默安装参考(亲测)
- 【POJ1323】Game Prediction 博弈,或者说贪心(本博客用栈处理)
- Objective-C之成魔之路【10-继承性】
- Fxcop入门
- hdu 5095 Linearization of the kernel functions in SVM(模拟)
- UVALive - 2326 Moving Tables
- windows中自定义消息
- 单文档客户区添加控件
- 关于IOS下唯一标识的方案比较
- mfc任意分割窗口