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 ...
随机推荐
- 开始linux课程预习工作
预习的过程,就是在老师讲课之前,自己学习的过程.重点,难点,疑点,不等老师先讲,自己先趟一遍,老师在讲的时候,相信会吸收的更好一些.
- 51nod 1392:装盒子 匈牙利+贪心
1392 装盒子 基准时间限制:1 秒 空间限制:131072 KB 分值: 160 难度:6级算法题 收藏 关注 有n个长方形盒子,第i个长度为Li,宽度为Wi,我们需要把他们套放.注意一个盒子 ...
- 实盘交易哪些代码BUG产生严重亏损
1.少写一个return,疯狂开平2900次,以爆仓结束 2.在上生产环境前,不小心误删除了一个“!”(我至今也不清楚为什么会误删了,晕),导致平仓逻辑一直不满足,不止损,让我损失惨重! 3.卖单变买 ...
- CountUp.js 数字跳转效果小插件
CountUp.js 实现数字跳转效果的小插件 //调用方法 const easingFn = function (t, b, c, d) { var ts = (t /= d) * t; var ...
- Mdb文件工具类,UCanAccess使用,Access数据库操作
================================ ©Copyright 蕃薯耀 2020-01-09 https://www.cnblogs.com/fanshuyao/ 使用Ocbc ...
- UVALive 3704 细胞自动机 矩阵快速幂
是时候要做做数学类的题目了 这属于比较简单的矩阵快速幂了,因为有个已知的矩阵循环的结论,所以为了节约时空,只需要保留一行即可,这个稍微有点难写,也不是难写,主要是注意细节.其他的矩阵快速幂一下即可 # ...
- 代码杂谈-python函数
发现函数可以设置属性变量, 如下 newfunc.func , newfunc.args def partial(func, *args, **keywords): """ ...
- zip4j 2.0压缩 加密压缩
https://github.com/srikanth-lingala/zip4j ZipParameters zipParameters = new ZipParameters(); zipPara ...
- Python笔记_第四篇_高阶编程_正则表达式_2.正则表达式入门
1. 匹配单个字符和数字: . --->> 匹配除换行符以外的任意字符.[0123456789] --->> []字符集合,表示匹配方括号中所包含的任意一个字符.[Thomas ...
- sudo apt-get update数字签名错误解决方法
lzb@lzb:~/projects/curl-master$ sudo apt-get update 命中: http://mirrors.aliyun.com/ubuntu xenial InRe ...