题意:有n个数字,带入10000 - (100 - ai) ^ 2公式得到n个数,输出n个数中频率最大的数,如果有并列就按值从小到大都输出输出,如果频率相同的数字是全部的n个数,就输出Bad。。。。
题解:统计数字个数和频率,排序后输出。

Sample Input
3
6
100 100 100 99 98 101
6
100 100 100 99 99 101
6
100 100 98 99 99 97

Sample Output
Case #1:
10000
Case #2:
Bad Mushroom
Case #3:
9999 10000

 # include <iostream>
# include <cstdio>
# include <cstring>
# include <algorithm>
# include <cmath>
# define LL long long
using namespace std ; struct Num
{
int cnt ;
int num ; }save[]; int v[] ; bool cmp(Num x , Num y)
{
return (x.cnt == y.cnt && x.num < y.num ||x.cnt > y.cnt) ;
} int main ()
{
//freopen("in.txt","r",stdin) ;
int T ;
scanf("%d" , &T) ;
int Case = ;
while(T--)
{
memset(v, , sizeof(v));
int n ;
scanf("%d" , &n) ;
int a ;
int i , j ;
int k = ;
for (i = ; i < n ; i++)
{
scanf("%d" , &a) ;
int t = - ( - a) * ( - a);
if (v[t] == )
{
v[t]++;
save[k].cnt = ;
save[k].num = t ;
k++ ;
}
else
v[t]++;
}
for (i = ; i < k ; i++)
save[i].cnt = v[save[i].num] ;
sort(save , save+k , cmp) ;
int m = ;
for (i = ; i < k - ; i++)
{
if (save[i].cnt == save[i + ].cnt)
m++;
else
break;
}
printf("Case #%d:\n" , Case++) ;
if (m == k && k!=)
{
printf("Bad Mushroom\n") ;
continue ;
}
for (i = ; i < m-; i++)
printf("%d " , save[i].num) ;
printf("%d\n" , save[m-].num) ;
} return ;
}

最新文章

  1. SpringMVC注解开发初步
  2. AD帐户操作C#示例代码(二)——检查密码将过期的用户
  3. 理清那么多个OO(面向对象)
  4. Nagios的安装配置与应用之五监控远程Linux服务器
  5. [ASP.NET MVC]如何定制Numeric属性/字段验证消息
  6. QCanvasItem介绍-QT3
  7. [测试题]数组(array)
  8. pycahrm 安装Vue项目
  9. Hive_1
  10. head first c初探网络编程上
  11. 课程五(Sequence Models),第三周(Sequence models &amp; Attention mechanism) —— 0.Practice questions:Sequence models &amp; Attention mechanism
  12. March 10th, 2018 Week 10th Saturday
  13. 那些IT行业的经典定律
  14. Error #2148
  15. jquery.uploadify 在firefox会出现httperror
  16. Publishing to IIS 发布到IIS
  17. OpenCV Save CvRect to File 保存CvRect变量到文件
  18. spark-sql执行流程分析
  19. 180729-Quick-Task 动态脚本支持框架之任务动态加载
  20. Asset Catalogs

热门文章

  1. Day12-navicat for sqlite 11.1.12 patch 永久使用版
  2. 【刷题】BZOJ 4316 小C的独立集
  3. net 和Mono 构建的HTTP服务框架
  4. 【Luogu P4149】[IOI2011]Race(点分治)
  5. Github Desktop 克隆仓库一直出现“Authentication failed”
  6. 【CF884D】Boxes And Balls k叉哈夫曼树
  7. TensorFlow最佳实践样例
  8. ELK应用之一:ELK平台搭建部署
  9. MyEclipse设置字体和背景的方法
  10. HDU 1730 类NIM模型