PAT 甲级 1041 Be Unique (20 分)
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,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.
Input Specification:
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.
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 分)的更多相关文章
- PAT 甲级 1041 Be Unique (20 分)(简单,一遍过)
1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is de ...
- PAT 甲级 1041. Be Unique (20) 【STL】
题目链接 https://www.patest.cn/contests/pat-a-practise/1041 思路 可以用 map 标记 每个数字的出现次数 然后最后再 遍历一遍 找到那个 第一个 ...
- 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. ...
- 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 ...
- 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 ...
- PAT 甲级 1035 Password (20 分)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...
- PAT 甲级 1073 Scientific Notation (20 分) (根据科学计数法写出数)
1073 Scientific Notation (20 分) Scientific notation is the way that scientists easily handle very ...
- PAT 甲级 1050 String Subtraction (20 分) (简单送分,getline(cin,s)的使用)
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be t ...
- PAT 甲级 1046 Shortest Distance (20 分)(前缀和,想了一会儿)
1046 Shortest Distance (20 分) The task is really simple: given N exits on a highway which forms a ...
随机推荐
- 6、什么是TypeScript、TypeScript的安装、转换为.js文件
1.什么是TypeScript (本人用自己的理解梳理了一下,不代表官方意见) TypeScript:Type+ECMAScript6 TypeScript是一种预处理编程语言,遵循es6标准规范,在 ...
- Delegate, NSNotification, KVO, Block
delegate: 当我们第一次编写iOS应用时,我们注意到不断的在使用“delegate”,并且贯穿于整个SDK.delegation模式不是iOS特有的模式,而是依赖与你过去拥有的编程背景.针对它 ...
- 浅谈对象的两个方法:Object.keys() ,Object.assign();
1 : Object.keys(obj) 返回给定对象的所有可枚举属性的字符串数组 例子1: var arr = [1, 2, 6, 20, 1]; console.log(Object.keys(a ...
- Mybatis 搭建遇到的坑
1. <?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapper PUBLIC " ...
- 阶段01Java基础day17集合框架03
17.01_集合框架(HashSet存储字符串并遍历) A:Set集合概述及特点 通过API查看即可 B:案例演示 HashSet存储字符串并遍历 HashSet<String> hs = ...
- Fiddler常用命令
几个常用的命令行方法使用: 查找对应响应码的数据包或请求类型的数据包: 输入“=post”将选择post的数据包并用蓝色底标色 输入:=502 查找服务器返回是图片类型的请求 输入 select im ...
- 北大poj- 1006
生理周期 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 133189 Accepted: 42577 Descripti ...
- python基础--字符串
字符串 1.形式 单引号括起来的字符串:'hello' 双引号括起来的字符串:"Hello" 三引号括起来的字符串:'''hello'''(三单引号),""&q ...
- 【转载】 星际争霸2的AI环境搭建
原文地址: https://blog.csdn.net/qq_40244666/article/details/80957644 作者:BOY_IT_IT 来源:CSDN -------------- ...
- Python全栈之路----函数----作用域
Python中,一个函数就是一个作用域. 局部变量放置在其作用域中,根据作用域来区分,函数属于你,函数属于我. 定义完成后,作用域已经生成,使用时顺着作用域链向上查找. 函数定义完成后,不管被在哪儿被 ...