题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=2456

给你一个n个数的数列,其中某个数出现了超过n div 2次即众数,请你找出那个数。

题解:因为众数出现超过n2\frac{n}{2}次,所以考虑抵消。剩下的必然是众数

#include <bits/stdc++.h>
#define pa pair<int, int>
#define mp make_pair
#define lowbit(x) ((x)&(-x))
#define mem(i, a) memset(i, a, sizeof(i))
#define sqr(x) ((x)*(x))
#define ls (k << 1)
#define rs (k << 1 | 1)
using namespace std;
typedef long long ll;
template <typename T>
inline void read(T &X) {
    X = 0; char ch = 0; T op = 1;
    for(; ch > '9' || ch < '0'; ch = getchar())
        if(ch == '-') op = -1;
    for(; ch >= '0' && ch <= '9'; ch = getchar())
        X = (X << 3) + (X << 1) + ch - 48;
    X *= op;
}

const int INF = 0x3f3f3f3f;
const int N = 1 + 5;

int main() {
#ifdef INCTRY
    freopen("input.txt", "rt", stdin);
#endif
    int n; cin >> n; cout << n / 2;


#ifdef INCTRY
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}