原题链接:
https://pintia.cn/problem-sets/994805342720868352/exam/problems/type/7?problemSetProblemId=994805444361437184&page=0
代码:
#include <iostream>
#include <vector>
using namespace std;
#define endl '\n'
int N;
vector<int> bets;
int times[10001];//记录每个赌注的出现次数
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//input
cin >> N;
for (int i = 0; i < N; i++) {
int tempBets;
cin >> tempBets;
bets.push_back(tempBets);
times[tempBets]++;
}
bool flag = false;//是否找到胜利数字
for (int i = 0; i < bets.size(); i++) {
if (times[bets[i]] == 1) {
cout << bets[i] << endl;
flag = true;
break;
}
}
if (!flag) {
cout << "None" << endl;
}
return 0;
}