HDU 5038 Grade (水题,坑题)

Posted dwtfukgv

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HDU 5038 Grade (水题,坑题)相关的知识,希望对你有一定的参考价值。

题意:给 n 个数,输出众数,但是如果所有的频率都相同但数不同输出 Bad Mushroom。

析:直接记录个数直接暴力就,就是要注意只有一种频率的时候。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <sstream>
#define debug() puts("++++");
#define gcd(a, b) __gcd(a, b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const LL LNF = 1e16;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 10000 + 10;
const int mod = 100000000;
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c){
  return r >= 0 && r < n && c >= 0 && c < m;
}

int a[maxn];

int main(){
  int T;  cin >> T;
  for(int kase = 1; kase <= T; ++kase){
    scanf("%d", &n);
    memset(a, 0, sizeof a);
    for(int i = 0; i < n; ++i){
      int x;
      scanf("%d", &x);
      x = 10000 - (100-x) * (100-x);
      ++a[x];
    }
    int mmax = 0;
    vector<int> v;
    int cnt = 0;
    for(int i = 0; i <= 10000; ++i){
      if(a[i] == 0)  continue;
      ++cnt;
      if(mmax < a[i]){
        v.clear();
        mmax = a[i];
        v.push_back(i);
      }
      else if(mmax == a[i])  v.push_back(i);
    }
    printf("Case #%d:\n", kase);
    if(cnt == 1)  printf("%d", v[0]);
    else if(cnt == v.size())  printf("Bad Mushroom");
    else  for(int i = 0; i < v.size(); ++i){
      if(i)  putchar(‘ ‘);
      printf("%d", v[i]);
    }
    printf("\n");
  }
  return 0;
}

  

以上是关于HDU 5038 Grade (水题,坑题)的主要内容,如果未能解决你的问题,请参考以下文章

HDU 6034 Balala Power! (贪心+坑题)

二分图匹配入门专题1I - Hiding Gold light oj 1152二分图匹配-------------------我是终于不那么水的水题分割线------------------(代码片

HDU 1846 Brave Game (博弈水题)

HDU 6182 A Math Problem 水题

HDU 5907 Find Q (水题)

HDU 3079 Vowel Counting (水题。。。判断元音)