https://pintia.cn/problem-sets/994805342720868352/problems/994805444361437184

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 <bits/stdc++.h>
using namespace std; const int maxn = 1e5 + 10;
int a[maxn], num[maxn]; int main() {
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i ++) {
scanf("%d", &a[i]);
num[a[i]] ++;
} int cnt = 0;
for(int i = 1; i <= n; i ++) {
if(num[a[i]] == 1) {
printf("%d\n", a[i]);
return 0;
}
if(num[a[i]] > 1)
cnt ++;
}
if(cnt == n)
printf("None\n");
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

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

  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. 【Mac】解决「无法将 chromedriver 移动到 /usr/bin 目录下」问题

    问题描述 在搭建 Selenium 库 + ChromeDriver 爬虫环境时,遇到了无法将 chromedriver 移动到 /usr/bin 目录下的问题,如下图: 一查原来是因为系统有一个 S ...

  2. 坚果云WebDav示例

    坚果云WebDav示例 最近看到坚果云有一个WebDAV应用,一时不解这是什么功能,了解后做了一个示例: WebDAV是一种基于HTTP1.1协议的通信协议.它扩展了HTTP1.1,在GET.POST ...

  3. 20155227 2016-2017-2《Java程序设计》课程总结

    20155227 2016-2017-2<Java程序设计>课程总结 (按顺序)每周作业链接汇总 预备作业1:我眼中的师生关系. 预备作业2:一些简单的C语言知识回顾,并总结之前一些成功的 ...

  4. apt-get 0%

    错误如下:      www.2cto.com   使用apt-get命令安装软件时出现“0%[正在等待报头]“的提示且无法继续安装,一般出现此问题是因为安装过程中Ctrl+C强行中断或其它原因导致上 ...

  5. Android开发——你真的了解Dialog、Toast和Snackbar吗

    0. 前言 今天给大家带来一篇简单易懂的关于Android提醒小功能的文章.Dialog和Toast我们都不陌生,而Snackbar是Design Support库中提供的新控件,有些朋友可能还不了解 ...

  6. day 12 文件操作

    1.文件定位读写  f.seek(2,0) ##### f.seek(2,0) In [4]: f = open("test.py","r") In [5]: ...

  7. SaltStack入门篇(二)之远程执行和配置管理

    1.远程执行 第一条命令: [root@linux-node1 master]# salt '*' test.ping linux-node2.example.com: True linux-node ...

  8. SQL优化避免索引失效

    Oracle 索引的目标是避免全表扫描,提高查询效率,但有些时候却适得其反.例如一张表中有上百万条数据,对某个字段加了索引,但是查询时性能并没有什么提高,这可 能是 oracle 索引失效造成的.or ...

  9. My status

    I haven‘t any one who is strong relationship with me. My skill is normal. I'm not interesting in neg ...

  10. 【转】在Android Studio中下载Android SDK的两种方式(Android Studio3.0、windows)

    在Android Studio中下载Android SDK的两种方式(Android Studio3.0.windows) 方式一.设置HTTP Proxy1. 打开Settings2. 点击HTTP ...