您的位置:首页 > 理论基础 > 计算机网络

acm icpc 北京网络赛 1007

2014-09-21 22:56 134 查看
这道题感觉不需要考虑太多,直接写就好了,稍微看一下就知道 s=10000-(200-w)^2 在w=1-200中只可能有100种可能

下面是ac代码:

#include <iostream>

#include <cstdio>

#include <cmath>

#include <cstring>

#include <algorithm>

#include <cstdlib>

#include <vector>

using namespace std;

int cot[10005];

vector <int> ans;

int main()

{

int t,n,w,s,maxn,num;

while(scanf("%d",&t)!=EOF)

{

for(int i=1;i<=t;i++)

{

ans.clear();

for(int j=1;j<=100;j++)

{

s=j*(200-j);

cot[s]=0;

}

maxn=0;

num=0;

scanf("%d",&n);

while(n--)

{

scanf("%d",&w);

s=w*(200-w);

cot[s]++;

if(cot[s]==1)

{

num++;

}

if(maxn<cot[s])

maxn=cot[s];

}

for(int j=1;j<=100;j++)

{

s=j*(200-j);

if(cot[s]==maxn)

{

ans.push_back(s);

}

}

printf("Case #%d:\n",i);

if(num==1)

{

printf("%d\n",ans[0]);

}

else if(ans.size()==num)

{

printf("Bad Mushroom\n");

}

else

{

sort(ans.begin(),ans.end());

printf("%d",ans[0]);

for(int j=1;j<ans.size();j++)

{

printf(" %d",ans[j]);

}

printf("\n");

}

}

}

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: