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,104]. 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.
Each input file contains one test case. Each case contains a line which begins with a positive integer N (≤105) and then followed by N bets. The numbers are separated by a space.
For each test case, print the winning number in a line. If there is no winner, print None instead.
7 5 31 5 88 67 88 17
31
5 888 666 666 888 888
None
题目要求的意思是找到给出数字中只出现过一次的数字,如果这种数字不止一个,则按照输入顺序,输出第一个只出现一次的数字。
这种问题就用map将数字和出现次数对应起来就可以了。然后再循环输入的数字,如果出现次数为1就直接输出。
1. 要输出第一个只出现一次的数字
- #include
- using namespace std;
-
- int main(){
- int N;
- cin>>N;
- map<int,int> number;
- int a[N];
-
-
相关阅读:
Vue.js3学习篇--Vue组件的属性和方法
Java 基础复习 Day 24
Xss跨站脚本攻击
leveldb安装
矿山自动驾驶技术点分析
Sentinel服务保护
探索k8s集群的存储卷 emptyDir hostPath nfs
cmake 代码版本管理
【深度学习实验】前馈神经网络(六):自动求导
SpringMvc之Json&全局异常处理
-
原文地址:https://blog.csdn.net/weixin_55202895/article/details/126438428