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 ...
随机推荐
- Jodd - Java界的瑞士军刀轻量级工具包!
Jodd介绍 Jodd是对于Java开发更便捷的开源迷你框架,包含工具类.实用功能的集合,总包体积不到1.7M. Jodd构建于通用场景使开发变得简单,但Jodd并不简单!它能让你把事情做得更好,实现 ...
- Java中循环体的初步了解以及另一种随机数的获取方法
Math中的相关操作 随机数 Java中除了可以直接导入Random类,获取随机数,还可以通过本身自带的Math方法去获取随机数.Math.random()可以产生随机小数,区间范围为[0.0,1.0 ...
- 分离vue文件,方便后期维护
参考: https://www.cnblogs.com/wy120/p/10179901.html https://blog.csdn.net/sinat_36146776/article/detai ...
- artTemplate不仅可以在浏览器中使用,还可以在node中使用
artTemplate不仅可以在浏览器中使用,还可以在node中使用 浏览器中引入lib/template-web.js node中 var template = require(‘art-tem ...
- Mr. Young's Picture Permutations
Mr. Young's Picture Permutations 给出一个有k列的网格图,以及每列图形的高度\(n_i\),下端对齐,保证高度递减,设有n个网格,询问向其中填1~n保证每行每列单调递增 ...
- 关于IOC
1. [调侃]IOC前世今生 http://www.cnblogs.com/showjan/p/3950989.html#!comments 2. 使用ConfigurationManager类 读写 ...
- springMVC项目创建及导入包项
springMVC项目创建及导入包项 - zhangzhetaojj的博客 - CSDN博客https://blog.csdn.net/zhangzhetaojj/article/details/50 ...
- 三次面试总结以及今后的todolist
金三银四跳槽季,按耐不住蠢蠢欲动的跳槽心,投了好多家的前端招聘,目前面了三家,有把握的零家.古人吾日三省吾身,我没那么高的觉悟,三面省一下自身,太咸鱼了是的我就是这么觉得的. 第一家公司在景田,很远, ...
- webpack打包指定HTML的文件并引入指定的chunks
1. 安装 html-webpack-plugin npm install html-webpack-plugin --save-dev 2. 在webpack.config.js中配置 const ...
- 通过挂钩NtCreateSection监控可执行模块
通过挂钩 NtCreateSection 监控可执行模块 在 Win32 中,我们使用 CreateFileMapping 来创建映射文件对象,函数原型如下: HANDLE CreateFileMap ...