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]. 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.

Input Specification:

Each input file contains one test case. Each case contains a line which begins with a positive integer N (≤) and then followed by N bets. The numbers are separated by a space.

Output Specification:

For each test case, print the winning number in a line. If there is no winner, print None instead.

Sample Input 1:

7 5 31 5 88 67 88 17

Sample Output 1:

31

Sample Input 2:

5 888 666 666 888 888

Sample Output 2:

None

 #include <iostream>
#include <unordered_map>
using namespace std;
int N, num[];
int main()
{
cin >> N;
unordered_map<int, int> numbers;
for (int i = ; i < N; ++i)
{
cin >> num[i];
numbers[num[i]]++;//为了保证单得到存数的位子顺序,借助num[i]
}
for (int i = ; i < N; ++i)
{
if (numbers[num[i]] == )
{
cout << num[i] << endl;
return ;
}
}
cout << "None" << endl;
return ;
}

PAT甲级——A1041 Be Unique的更多相关文章

  1. PAT 甲级 1041 Be Unique (20 分)

    1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is desi ...

  2. PAT 甲级 1041 Be Unique

    https://pintia.cn/problem-sets/994805342720868352/problems/994805444361437184 Being unique is so imp ...

  3. PAT 甲级 1041 Be Unique (20 分)(简单,一遍过)

    1041 Be Unique (20 分)   Being unique is so important to people on Mars that even their lottery is de ...

  4. PAT甲级——1041 Be Unique

    1041 Be Unique Being unique is so important to people on Mars that even their lottery is designed in ...

  5. PAT 甲级 1041. Be Unique (20) 【STL】

    题目链接 https://www.patest.cn/contests/pat-a-practise/1041 思路 可以用 map 标记 每个数字的出现次数 然后最后再 遍历一遍 找到那个 第一个 ...

  6. PAT甲级题解(慢慢刷中)

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  7. PAT甲级题解分类byZlc

    专题一  字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...

  8. PAT甲级:1089 Insert or Merge (25分)

    PAT甲级:1089 Insert or Merge (25分) 题干 According to Wikipedia: Insertion sort iterates, consuming one i ...

  9. PAT甲级:1064 Complete Binary Search Tree (30分)

    PAT甲级:1064 Complete Binary Search Tree (30分) 题干 A Binary Search Tree (BST) is recursively defined as ...

随机推荐

  1. 牛客多校第六场 J Upgrading Technology dp

    题意: 有n个技能,一开始都是0级,第i个技能从j-1级升到j级,花费$c_{i,j}$,但是花费不一定是正的 所有的技能升到j级时,奖励$d_j$但是奖励也不一定是正的 题解: 用sum[i][j] ...

  2. php数据结构课程---7、队列实战

    php数据结构课程---7.队列实战 一.总结 一句话总结: 注意条件:注意循环的条件(比如while循环打印队列元素时),注意if的条件 把问题想清楚:比如链表操作初次插入元素和后面再插,效果是不一 ...

  3. VS2010-MFC(常用控件:按钮控件的编程实例)

    转自:http://www.jizhuomi.com/software/184.html 因为Button控件在前面的例子中涉及到了,比较简单,本文就不作深入分析了,而是重点讲解单选按钮Radio B ...

  4. css3 鼠标悬浮动画效果

    CSS3案例 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <ti ...

  5. 基于UDP协议的套接字编程

    基于udp协议的套接字编程 UDP是无链接的,先启动那一端都不会报错 UDP协议是数据报协议,发空的时候也会自带报头,因此客户端输入空,服务端也能收到 一般不用与传输大数据 虽然没有粘包问题,但是不能 ...

  6. python爬取凤凰网站的新闻,及其链接地址,来源,时间和内容,用selenium自动化和requests处理数据

    有写规则需要自己定义判断. import requests from selenium import webdriver import time def grasp(urlT): driver = w ...

  7. jQuery鼠标拖曳改变div大小(模拟textarea右下角拖曳)

    jQuery.fn.extend({ drag: function() { $(document).off("mouseup.drag").on("mouseup.dra ...

  8. Java开发系列-时间转换

    获取当前时间戳 // 获取当前的时间戳 long time = new Date().getTime(); 将字符串时间戳转成格式的时间字符串 Long timestrap = Long.parseL ...

  9. mongodb 3.2 yaml 配置详解及范例

    mongodb3.x版本后就是要yaml语法格式的配置文件,下面是yaml配置文件格式如下:官方yaml配置文件选项参考:https://docs.mongodb.org/manual/ ... #c ...

  10. 【数位DP】[LOJ10168] 恨7不成妻

    还是数位DP... 状态:$f[x][val][sum]$表示当前第x位,当前数字为val,当前各位数字和为sum 观察到$val$,$sum$过大,很套路地模7即可... 每个状态存储三个要用到的值 ...