PAT甲级——A1041 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]. 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 (≤) 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 <unordered_map>
using namespace std;
int N, num[];
int main()
{
cin >> N;
unordered_map<int, int> numbers;
for (int i = ; i < N; ++i)
{
cin >> num[i];
numbers[num[i]]++;//为了保证单得到存数的位子顺序,借助num[i]
}
for (int i = ; i < N; ++i)
{
if (numbers[num[i]] == )
{
cout << num[i] << endl;
return ;
}
}
cout << "None" << endl;
return ;
}
PAT甲级——A1041 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
https://pintia.cn/problem-sets/994805342720868352/problems/994805444361437184 Being unique is so imp ...
- 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
1041 Be Unique Being unique is so important to people on Mars that even their lottery is designed in ...
- PAT 甲级 1041. Be Unique (20) 【STL】
题目链接 https://www.patest.cn/contests/pat-a-practise/1041 思路 可以用 map 标记 每个数字的出现次数 然后最后再 遍历一遍 找到那个 第一个 ...
- PAT甲级题解(慢慢刷中)
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...
- PAT甲级题解分类byZlc
专题一 字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...
- PAT甲级:1089 Insert or Merge (25分)
PAT甲级:1089 Insert or Merge (25分) 题干 According to Wikipedia: Insertion sort iterates, consuming one i ...
- PAT甲级:1064 Complete Binary Search Tree (30分)
PAT甲级:1064 Complete Binary Search Tree (30分) 题干 A Binary Search Tree (BST) is recursively defined as ...
随机推荐
- VS2010-MFC(图形图像:GDI对象之画刷CBrush)
转自:http://www.jizhuomi.com/software/248.html 上一节讲的是画笔CPen的用法,前面也说了,GDI对象中最常用的就是画笔和画刷,本节就讲讲画刷CBrush. ...
- iOS之SceneKit.h文件简介
1.SceneKit简介 SceneKit(SK)是WWDC12推出的OS X平台的Cocos 3D渲染引擎框架.支持粒子效果,物理模拟,脚本事件,多程渲染,支持iOS平台.SceneKit整合了Co ...
- 样本方差的抽样分布 χ2(n) 卡方分布_样本方差 卡方分布
样本方差的抽样分布 χ2(n) 卡方分布_样本方差 卡方分布 样本方差的抽样分布 χ2(n) 卡方分布 t分布.卡方分布.f分布均要求总体服从正态分布. 若n个相互独立的随机变量ξ1,ξ2,-,ξn ...
- 数据库连接JDBC
#=======================mysql============================= #jdbc.driverClassName=com.mysql.jdbc.Driv ...
- idea激活破解
下载链接:https://pan.baidu.com/s/1BADk1MCm0YxtB6zoX0DivA 提取码 ze9m将破解补丁放到bin文件中jetbrains-all.jar 在这俩个文件最后 ...
- 洛谷P3834【模板】可持久化线段树 1(主席树)
题目背景 这是个非常经典的主席树入门题--静态区间第K小 数据已经过加强,请使用主席树.同时请注意常数优化 题目描述 如题,给定N个正整数构成的序列,将对于指定的闭区间查询其区间内的第K小值. 输入输 ...
- C++ 系列:typedef 和 #define 的区别
总结一下typedef和#define的区别 1.概念 #define 它在编译预处理时进行简单的替换,不作正确性检查.它是预处理指令. typedef 它在自己的作用域内给一个已经存在的类型一个别名 ...
- 用shell编写小九九乘法表程序
1.使用for循环 运行结果: 2.方法二:for循环 运行结果: 备注: 1. echo -n 的意思是不自动换行,因为在linux shell中 echo到最后一个字符时会自动换行的,所以echo ...
- 廖雪峰Java13网络编程-1Socket编程-1网络编程概念
1.计算机网络 1.1 什么是计算机网络? 两台或更多计算机组成的网络 同一网络内的任意2台计算机都可以直接通信 所有计算机必须遵循同一种网络协议 1.2 什么是互联网 互联网是网络的网络 互联网采用 ...
- Python 变量与数据类型
1.变量命名规则: 变量名只能是字母,数字和下划线的任意组合 变量名第一个字符不能是数字 变量名区分大小写,大小写字母被认为是两个不同的字符 特殊关键字不能命名为变量名 2.数值的运算 print ( ...