poj1323
来源:互联网 发布:网络语鬼畜啥意思 编辑:程序博客网 时间:2024/04/30 13:50
#include<iostream>#include<queue>#include<algorithm>using namespace std;int main(){int m,n,i,a,b,win,times=0;deque<int>me,other;deque<int>::iterator it;while((cin>>m>>n)){if(m==0&&n==0) break; me.resize(n); other.resize(n*m-n);win=0;times++;for(i=0;i<n;i++)cin>>me[i];for(i=1;i<=n*m;i++){it=find(me.begin(),me.end(),i);if(it==me.end()) other.push_back(i);}sort(me.begin(),me.end());while(!me.empty()){a=me.back();b=other.back();me.pop_back();if(a>b) {win++;for(i=1;i<m;i++) other.pop_front();}else {other.pop_back();for(i=1;i<m-1;i++)other.pop_front();}}cout<<"Case "<<times<<": "<<win<<endl;}}
#include "iostream"//此代码转载using namespace std;int main(){ int n,m,i,num,result,top,ncase; ncase=1; while (cin>>m>>n&&m!=0&&n!=0) { result=0; top=0; int flag[10000]={-1}; for (i=0;i<n;i++) { cin>>num; flag[num]=1; } for (i=m*n;i>0;i--) { if (flag[i]) { if (top>0) { top--; } else { result++; } } else { top++; } } cout << "Case " << ncase++ << ": " << result << endl; } return 0;}