A1041 Be Unique (20)

摘要
Title: A1041 Be Unique (20)
Tag: 模拟
Memory Limit: 64 MB
Time Limit: 1000 ms

Powered by:NEFU AB-IN

Link

A1041 Be Unique (20)

  • 题意

    Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1,10^4]. The first one who bets on a unique number wins. For example, if there are 7 people betting on { 5 31 5 88 67 88 17 }, then the second one who bets on 31 wins.

  • 思路

    模拟即可

  • 代码

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    /*
    * @Author: NEFU AB-IN
    * @Date: 2023-01-09 19:15:51
    * @FilePath: \GPLT\A1041\A1041.cpp
    * @LastEditTime: 2023-01-09 19:18:16
    */
    #include <bits/stdc++.h>
    using namespace std;
    #define int long long
    #undef int

    #define SZ(X) ((int)(X).size())
    #define ALL(X) (X).begin(), (X).end()
    #define IOS \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr); \
    cout.tie(nullptr)
    #define DEBUG(X) cout << #X << ": " << X << '\n'
    typedef pair<int, int> PII;

    const int N = 1e5 + 10, INF = 0x3f3f3f3f;

    signed main()
    {
    IOS;
    int n;
    unordered_map<int, int> mp;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    cin >> a[i], mp[a[i]]++;

    for (auto &num : a)
    {
    if (mp[num] == 1)
    {
    cout << num;
    return 0;
    }
    }
    cout << "None";
    return 0;
    }
使用搜索:谷歌必应百度