POJ 1323 Game Prediction
来源:互联网 发布:sql start with 树状 编辑:程序博客网 时间:2024/05/17 02:27
纸牌游戏,
M人每人N张牌。
每轮如果有人能比你的牌更大,你就赢不了。
如:
2 5
1 7 2 10 9;
总共 2*5=10张牌,你手里5张。
当你10的时候,没有比你更大的。
9的时候也是,其他时候都可能比你大。
所以答案为2.
不过输出的时候Case %d: %d\n居然这儿总共2个空格。害我PE一次。
POJ AC代码
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;bool cmpa(int a,int b){ return a>b;}int main(){ int n,m,i,j,a[51],v[1001],k=1; while(scanf("%d%d",&m,&n),m!=0&&n!=0) { memset(v,0,sizeof(v)); for(i=0;i<n;i++) scanf("%d",&a[i]),v[a[i]]=1; int tmp=0,ma=m*n,ans=0; sort(a,a+n,cmpa); for(i=0;i<n;i++) { for(j=ma;j>0;j--) { if(v[j]==0) { if(j<a[i]) {ans++;break;} else {v[j]=1;break;} } } } printf("Case %d: %d\n",k++,ans); }}
- 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 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 1323 Game Prediction 题解
- POJ 1323 Game Prediction 笔记
- POJ 1323-Game Prediction(贪心)
- POJ——1323 Game Prediction
- Objective-C如何使用 Web 服务之学习系列五
- C++ - "replace" 和 "replace_copy" 区别
- JAVA学习脚印 :日志文件的使用
- JAVA加强——枚举
- MHA自动Failover过程解析(updated) ------好东西 分享一下
- POJ 1323 Game Prediction
- mysql安装及使用实例
- ext.net 当有选择行时按钮才生效
- EBS初始化用户密码脚本
- java中常用的字符串的截取方法
- 你懂黑客在说什么吗?
- soj dsa extra 1002 sudoku
- mysql数据库查询数据库都有哪些用户的命令
- android.widget.ImageView