PAT甲级——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,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 <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的更多相关文章
- PAT 甲级 1041 Be Unique (20 分)
1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is desi ...
- 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
https://pintia.cn/problem-sets/994805342720868352/problems/994805444361437184 Being unique is so imp ...
- PAT 甲级 1041. Be Unique (20) 【STL】
题目链接 https://www.patest.cn/contests/pat-a-practise/1041 思路 可以用 map 标记 每个数字的出现次数 然后最后再 遍历一遍 找到那个 第一个 ...
- 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】1041. Be Unique (20)
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1041 题目描述: Being unique is so important to people ...
- 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甲级——A1041 Be Unique
Being unique is so important to people on Mars that even their lottery is designed in a unique way. ...
- 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 ...
随机推荐
- Java8集合框架——集合工具类Arrays内部方法浅析
java.util.Arrays 备注:本文只对 Java8 中的 java.util.Arrays 中提供的基本功能进行大致介绍,并没有对其具体的实现原理进行深入的探讨和分析.详情可自己深入观摩源码 ...
- Python说文解字_Python之多任务_03
问:线程学完了,现在我们开始学习进程了吧? 答:是的.前面说到线程就是我们的手,我们现在可以学习一下我们的“胳膊”了. 我们有了多线程,为什么还要学习多进程呢?这是因为在Python当中有一把GIL锁 ...
- Windbg 大改版,值得期待
早上从twitter上面看到一篇文章,看到windbg会提供一个Time Travel Debugging(TTD) 功能,该功能会在未来的版本引入. Time travel debugging: I ...
- Unity获取游戏对象详解
我觉得Unity里面的Transform 和 GameObject就像两个双胞胎兄弟一样,这俩哥们很要好,我能直接找到你,你也能直接找到我.我看很多人喜欢在类里面去保存GameObject对象.解决G ...
- 吴裕雄--天生自然 JAVASCRIPT开发学习: DOM - 改变 HTML
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- 寒假day14
今天去医院看脸了,回来继续写论文.
- javaweb03 javaservlet基础一
1.使用JavaEE版的eclipse开发动态的WEB工程(JavaWEB 项目)1).把开发选项切换到JavaEE2).可以在window -> Show View 中找到Package Ex ...
- MySQL--索引和外键
来自:http://www.jb51.net/article/32149.htm 1.添加PRIMARY KEY(主键索引) ALTER TABLE `table_name` ADD PRIMARY ...
- 增删改查(简单版&连接数据库)
这个博客也是补充之前的学习内容: 项目总述:这个增删改查我以,选课名称,选课教室,选课教师基本信息,作为主要的信息来源.主要对这些信息最基本的增删改查 详细的分析与说明: 1.首先在src文件里定义四 ...
- 18 11 05 继续补齐对python中的class不熟悉的地方 和 pygame 精灵
---恢复内容开始--- class game : #历史最高分----- 是定义类的属性 top_score =0 def __init__(self, player_name) : #是定义的实例 ...