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;
}
下面是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;
}
相关文章推荐
- 2014北京网络赛1007||hdu5038 模拟
- 浅谈ACM ICPC的题目风格和近几年题目的发展
- 产品设计体会(1007)需求,分析什么
- DNA Sorting-PKU ACM 1007
- pku1007 poj 1007 hdu1379 DNA Sorting
- 人民大学云计算编程的网上评估平台--解题报告 1004-1007
- hdu 1007 Quoit Design (最近点对、分治)
- 2011北京网络赛G
- 1007 DNA Sorting
- POJ 1007 DNA Sorting
- poj 1007 DNA Sorting
- hdu 1007 Quoit Design
- hdu 4284 Travel (2012 天津网络赛 1007 )
- 杭电 1007
- 浙大PAT 1007题 1007. Maximum Subsequence Sum
- 1007
- 寒假练习 1007 Number Converter
- POJ_1007 DNA Sorting
- timus_1007_bfs
- POJ 1007 DNA Sorting