1041 Be Unique

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 <string>
using namespace std;

int main(void)
{
int a[100001] = {0};
int b[100001] = {0};//用来区别该数字是否重复出现
int n,flag=0;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> a[i];
b[a[i]]++;
}
for (int i = 0; i < n; i++)
{
if (b[a[i]] == 1)
{
cout << a[i] << endl;
return 0;
}
}
if (flag == 0)
cout << "None" << endl;
return 0;
}

PAT甲级——1041 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 (20 分)(简单,一遍过)

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

  3. PAT 甲级 1041 Be Unique

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

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

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

  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】1041. Be Unique (20)

    题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1041 题目描述: Being unique is so important to people ...

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

  8. PAT甲级——A1041 Be Unique

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

  9. PAT Advanced 1041 Be Unique (20) [Hash散列]

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

随机推荐

  1. OpenCV2基础操作----直线、矩形、圆、椭圆函数的使用

    opencv2几个画图函数的调用 要用到几个随机变量: int fr = rand()%frame.rows; int fc = rand()%frame.cols; int b = rand()%2 ...

  2. 使用maven打包问题

    项目打包:选择项目 右键->run as-> maven install . 项目中使用的是maven项目,将项目打包成war的时候有时候会出现 出现这种情况的时候解决步骤如下: 选择要打 ...

  3. webapi 传入参数校验

    /// <summary> /// 传入参数校验过滤器 /// </summary> public class ValidateReqModelFilter : ActionF ...

  4. JDK的3个bug啊,你get到了吗?

    1.Annotation引用非空enum数组返回空数组 首次发现时的环境:JDK 1.8 首次发现所在项目:APIJSON 测试用例: publicenumRequestRole {/**未登录,不明 ...

  5. JavaScript—面向对象 贪吃蛇_2 食物对象

    食物对象 //自调用 (function (){ function Food(element) { this.width = 20 this.height = 20 this.backgroundCo ...

  6. ubuntu下git的使用

    1.安装git sudo apt-get install git sudo apt-get install git-core 2.配置git lzb@lzb:~$ git config --globa ...

  7. mqtt+htttp+websocket

    一.介绍 1.参考网址1:WebSocket协议:5分钟从入门到精通 2.参考网址2:WebSocket 教程(阮一峰) 二.应用 1.参考网址1:从 HTTP 到 MQTT:一个移动后端案例概述 2 ...

  8. php 查看接口运行时间

    代码如何: <?php $start_time = microtime(true); for ($i=0;$i<100000000;$i++){}; $end_time = microti ...

  9. Centos8无法安装screen的解决方法:使用epel安装screen

    选择了一个基础款的vps安装的镜像选了熟悉的centos的最新版centos8,但是在安装screen的时候,却安装不了,提示: No match for argument: screen 本来以为是 ...

  10. 吴裕雄--天生自然ShellX学习笔记:Shell 流程控制

    和Java.PHP等语言不一样,sh的流程控制不可为空,如(以下为PHP流程控制写法): <?php if (isset($_GET["q"])) { search(q); ...