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

Input Specification:

Each input file contains one test case. Each case contains a line which begins with a positive integer N (≤10​5​​) 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<map> using namespace std; int main()
{
int N, temp, index = , min = ;
map<int, int> m; cin >> N; for (int i = ; i<N; ++i)
{
cin >> temp; if (m.find(temp) == m.end())
m.insert(pair<int, int>(temp, index++));
else
m[temp] = ;
} map<int, int>::iterator begin = m.begin(), end = m.end(), i, minIndex; for (i = begin; i != end; ++i)
{
if (i->second> && i->second<min)
{
min = i->second;
minIndex = i;
}
} if (min == )
cout << "None" << endl;
else
cout << minIndex->first << endl;
}

PAT 甲级 1041 Be Unique (20 分)的更多相关文章

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

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

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

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

  3. PAT Advanced 1041 Be Unique (20 分)

    Being unique is so important to people on Mars that even their lottery is designed in a unique way. ...

  4. PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642 题目描述: Being unique is so important to peo ...

  5. PAT甲 1041. Be Unique (20) 2016-09-09 23:14 33人阅读 评论(0) 收藏

    1041. Be Unique (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Being uniqu ...

  6. PAT 甲级 1035 Password (20 分)

    1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...

  7. PAT 甲级 1073 Scientific Notation (20 分) (根据科学计数法写出数)

    1073 Scientific Notation (20 分)   Scientific notation is the way that scientists easily handle very ...

  8. PAT 甲级 1050 String Subtraction (20 分) (简单送分,getline(cin,s)的使用)

    1050 String Subtraction (20 分)   Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be t ...

  9. PAT 甲级 1046 Shortest Distance (20 分)(前缀和,想了一会儿)

    1046 Shortest Distance (20 分)   The task is really simple: given N exits on a highway which forms a ...

随机推荐

  1. git创建分支提交到远程分支步骤

    git创建分支提交到远程分支步骤 step1,在本地新建分支() git branch newbranch step2:把本地分支push到远程 git push origin newbranch s ...

  2. Linux进程间通信机制

    Linux支持管道.信号.unix system V三种IPC(Inter-Process-Communication)机制.以下分别对三种机制加以简单介绍. 一.信号机制: 信号又称作软中断,用来通 ...

  3. 关于WebUpload插件的使用

    上传的路径地址: 删除图片时也应该注意: unlink('/Upload/1.jpg')删除不了 unlink('./Upload/1.jpg')可以删除. 也就是说,绝对路径删除不了  相对路径可以 ...

  4. jquery常用实例

    $("#returnTop").click(function () { var speed=200;//滑动的速度 $('body,html').animate({ scrollT ...

  5. leetcode题解 3. Longest Substring Without Repeating Characters

    题目: Given a string, find the length of the longest substring without repeating characters. Examples: ...

  6. HttpConnection详解【转】

    HttpConnection详解[转]   HttpURLConnection对象  1.从Internet获取网页,发送请求,将网页以流的形式读回来. 步骤:1)创建一个URL对象:URL url ...

  7. java基础(5)内部类

    1 成员内部类的定义和使用 public class Outer { private String name; public class Inner { public void innerMethod ...

  8. jupyter notebook中使用mpld3进行交互

    用pycharm进行远程服务器debug可以说是非常的爽了,但是设置远程的图片在本地显示会非常的麻烦 jupyter可以用%matplotlib inline 来远程plt.show图片,但是有一个问 ...

  9. Python全栈之路----函数进阶----列表生成式

    列表生成式 现在有个需求,看列表[0,1,2,3,4,5,6,7,8,9],要求你把列表里每个值都加1,你怎么实现?你可能会想到两种方法. 二逼青年版 >>> a = [0,1,2, ...

  10. 洛谷P1357 花园(状态压缩 + 矩阵快速幂加速递推)

    题目链接:传送门 题目: 题目描述 小L有一座环形花园,沿花园的顺时针方向,他把各个花圃编号为1~N(<=N<=^).他的环形花园每天都会换一个新花样,但他的花园都不外乎一个规则,任意相邻 ...