PAT_A1041#Be Unique
Source:
Description:
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
Keys:
- 哈希映射
Code:
/*
Data: 2019-07-21 20:19:03
Problem: PAT_A1041#Be Unique
AC: 07:07 题目大意:
找出数列中仅出现一次的数
*/ #include<cstdio>
using namespace std;
const int M=1e5+;
int lot[M],mp[M]={}; int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("Test.txt", "r", stdin);
#endif int n;
scanf("%d", &n);
for(int i=; i<n; i++)
{
scanf("%d", &lot[i]);
mp[lot[i]]++;
}
for(int i=; i<n; i++)
{
if(mp[lot[i]]==)
{
printf("%d", lot[i]);
n=;break;
}
}
if(n) printf("None"); return ;
}
PAT_A1041#Be Unique的更多相关文章
- [LeetCode] Unique Substrings in Wraparound String 封装字符串中的独特子字符串
Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...
- [LeetCode] Minimum Unique Word Abbreviation 最短的独一无二的单词缩写
A string such as "word" contains the following abbreviations: ["word", "1or ...
- [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...
- [LeetCode] Unique Word Abbreviation 独特的单词缩写
An abbreviation of a word follows the form <first letter><number><last letter>. Be ...
- [LeetCode] Unique Binary Search Trees 独一无二的二叉搜索树
Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...
- [LeetCode] Unique Binary Search Trees II 独一无二的二叉搜索树之二
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For e ...
- [LeetCode] Unique Paths II 不同的路径之二
Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How m ...
- [LeetCode] Unique Paths 不同的路径
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The ...
- 2 Unique Binary Search Trees II_Leetcode
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For e ...
随机推荐
- jackson反序列化报错Unrecognized field , not marked as ignorable
使用Jackson提供的json注解. @JsonIgnore注解用来忽略某些字段,可以用在Field或者Getter方法上,用在Setter方法时,和Filed效果一样.这个注解只能用在POJO存在 ...
- main()和代码块
main方法 * main()方法的使用说明 * main方法是程序的主入口(一个主程序 先从main开始进行执行) * * * main方法也可以是一个普通的静态方法 代码块 代码块也是类的成员变量 ...
- sql合并字段
<!-- 对发送方式合并查询 --> <!--查询所有满足条件的营销活动 --> <select id="CRM-MK-ACT-DEFINE-SELECT&qu ...
- spark sql数据源--hive
使用的是idea编辑器 spark sql从hive中读取数据的步骤:1.引入hive的jar包 2.将hive-site.xml放到resource下 3.spark sql声明对hive的支持 案 ...
- Eureka 系列(05)消息广播(上):消息广播原理分析
Eureka 系列(05)消息广播(上):消息广播原理分析 [TOC] 0. Spring Cloud 系列目录 - Eureka 篇 首先回顾一下客户端服务发现的流程,在上一篇 Eureka 系列( ...
- Scrapy框架: 基本命令
1.创建爬虫项目 scrapy startproject [项目名称] 2.创建爬虫文件 scrapy genspider +文件名+网址 3.运行(crawl) scrapy crawl 爬虫名称 ...
- Python 字符串常用判断函数
判断字符串常用函数: S代表某字符串 S.isalnum() 所有字符都是数字或字母,为真返回Ture,否则返回False S.isalha() 所有字符都是字母,为真返回Ture,否则返回 ...
- ArcGis基础——设置图层可选状态
在ArcMap的图层列表上右键,可以设置“仅本图层可选”. 那么,如何设置回多个或者全部图层可选状态呢? 1.在ArcMap的菜单栏找到 自定义——自定义模式——选择——设置可选图层. 2.将“设置可 ...
- Grep的过滤使用
grep的过滤使用 已知文件test里有以下内容 [root@yangwenbo /]# cat test yuni yunwei YUNWEI YWEI yunjijsuan yunsuan YUN ...
- Codeforces 348E 树的中心点的性质 / 树形DP / 点分治
题意及思路:http://ydc.blog.uoj.ac/blog/12 在求出树的直径的中心后,以它为根,对于除根以外的所有子树,求出子树中的最大深度,以及多个点的最大深度的lca,因为每个点的最长 ...