PAT 甲级 1041 Be Unique (20 分)

时间:2022-09-08 14:25:19
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 &lpar;20 分&rpar;(简单&comma;一遍过)

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

  2. PAT 甲级 1041&period; Be Unique &lpar;20&rpar; 【STL】

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

  3. PAT Advanced 1041 Be Unique &lpar;20 分&rpar;

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

  4. PAT &lpar;Advanced Level&rpar; Practice 1041 Be Unique &lpar;20 分&rpar; 凌宸1642

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

  5. PAT甲 1041&period; Be Unique &lpar;20&rpar; 2016-09-09 23&colon;14 33人阅读 评论&lpar;0&rpar; 收藏

    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 &lpar;20 分&rpar; &lpar;根据科学计数法写出数&rpar;

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

  8. PAT 甲级 1050 String Subtraction &lpar;20 分&rpar; (简单送分&comma;getline&lpar;cin&comma;s&rpar;的使用)

    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 &lpar;20 分&rpar;(前缀和&comma;想了一会儿)

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

随机推荐

  1. Java实现验证码制作之一Kaptcha验证码

    Kaptcha验证码 是google提供的验证码插件,使用起来相对简单,设置的干扰线以及字体扭曲不易让其他人读取破解. 这里我们需要 导入一个 kaptcha-2.3.jar  下载地址:http:/ ...

  2. &lbrack;水煮 ASP&period;NET Web API2 方法论&rsqb;(3-9)空气路由的设置

    阅读导航 问题 解决方案 工作原理 代码演示 在此解释一下,空气路由,是本人臆想出来,觉着更能表达 IgnoreRoute 的意图,如果看着辣眼睛^^,请见谅. 问题 我们在之定义过集中式路由,集中式 ...

  3. poj 3295 Tautology

    点击打开链接 Tautology Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8127   Accepted: 3115 ...

  4. mysql去除重复查询的SQL语句基本思路

    SELECT R.* FROM trans_flow R, (SELECT order_no, MAX(status_time) AS status_time FROM trans_flow GROU ...

  5. Erlang中的图形化检测工具(4)

    这儿例举出若干个用于检视运行时系统的图形化工具,这些工具可以很好地帮助我们增进对系统的理解.借助这些工具,我们可以很好地以图形化方式观察进程.应用和监督层级. (1) Appmon.Appmon 是用 ...

  6. SpringMVC请求访问不到静态文件解决方式

    如何你的DispatcherServlet拦截"*.do"这样的有后缀的URL,就不存在访问不到静态资源的问题. 如果你的DispatcherServlet拦截"/&qu ...

  7. Silverlight技术调查&lpar;2&rpar;——跨域访问

    原文 Silverlight技术调查(2)——跨域访问 此调查web容器采用的是Tomcat,若允许所有域访问,只需在webapps下的根应用ROOT中,加入配置文件:clientaccesspoli ...

  8. webstrom30天免费试用期过后如何破解继续使用

    之前下了ws 直接就用了 也没有破解 30天过去了 老是提示你 神烦  网上找了一堆注册码什么的 终于发现一个良心网站 http://idea.qinxi1992.cn/ 步骤看下面的图

  9. 查看Windows端口及端口关闭方法

    一.查看已开放的端口: 1.借助系统自带MS-DOS命令查看开放的端口(Win2000/XP/server2003) 在开始-运行-输入cmd,打入netstat -an(注意-前有个小空格),在IP ...

  10. Python 爬虫笔记(三)

    from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains #Act ...