65,211
社区成员
发帖
与我相关
我的任务
分享#include<iostream>
#include<vector>
using namespace std;
int main(){
int m=1,n=1,temp,w=0,e=0,max=0;
vector<int> a,b;
while(cin>>m>>n && n!=0 && m!=0){
if(m>=20 && m<=2 && n>=50 && n<=1) exit(1);
for(int i=0;i<n;i++){
cin>>temp;
if(temp>m*n && temp<=0) exit(1);
a.push_back(temp);
}
for(int temp=n*m;temp>0;temp--){
int x=0;
for(int i=0;i<n;i++)
if(temp==a[i]) { w++; x=1; }
if(x==0) e++;
max=(max>w-e) ? max:w-e;
}
b.push_back(max);
cout<<"\n";
}
for(unsigned int i=0;i<b.size();i++)
cout<<"Case "<<i+1<<": "<<b[i]<<endl;
return 1;
}