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, 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<cstdio>
#include<iostream>
using namespace std;
int hashTB[] = {,}, record[];
int main(){
int N, find = -;
scanf("%d", &N);
for(int i = ; i < N; i++){
scanf("%d", &record[i]);
hashTB[record[i]]++;
}
for(int i = ; i < N; i++){
if(hashTB[record[i]] == ){
find = i;
break;
}
}
if(find == -)
printf("None");
else printf("%d", record[find]);
cin >> N;
return ;
}
总结:
1、本题题意:按照输入的顺序,找出第一个只出现一次的数字并输出。
A1041. Be Unique的更多相关文章
- PAT甲级——A1041 Be Unique
Being unique is so important to people on Mars that even their lottery is designed in a unique way. ...
- A1041 Be Unique (20 分)
一.技术总结 这题在思考的时候遇见了,不知道怎么处理输入顺序问题,虽然有记录每个的次数,事后再反过来需要出现一次的且在第一次出现, 这时我们其实可以使用另一个数组用来存储输入顺序的字符,然后再用另一个 ...
- PAT_A1041#Be Unique
Source: PAT A1041 Be Unique (20 分) Description: Being unique is so important to people on Mars that ...
- PAT甲级题解分类byZlc
专题一 字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...
- 1041 Be Unique (20 分)
1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is desi ...
- [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 ...
随机推荐
- 树莓派Opencv张正友棋盘标定法
make.Makefile cc = gcc #最简易的makefile文件,这个可以用来进行文件之间的简易构建和链接,生成我们所需要的执行文件: prom = calc deps = $(shell ...
- Nginx+Tomcat+Memcached部署
环境清单列表:(因为只有三台电脑,所有把Nginx和memcached放到一起) 应用服务器1:192.168.51.10: 应用服务器2:192.168.55.110: memcached服务器:1 ...
- wordcount程序中的应用与拓展
设计思路: 关键是思路,首先知道 单词, 行,字符, 他们有什么特点: 1.单词,标准的是遇到空格后,单词数,自动加一. 2.行是以\n结束的, 也就是说, 遇到\n行数加一,当然也视你的操作系统而言 ...
- 复审Partner
复审代码后,发现了一些问题: 首先说优点:代码十分工整,很清晰,各种类易于理解,逻辑上很通顺. 基本实现了代码功能,输出正确. 发现的缺点:对于文件后缀的识别有点问题,不能识别所需求的所有文件,只有一 ...
- linux第三次实践:ELF文件格式分析
linux第三次实践:ELF文件格式分析 标签(空格分隔): 20135328陈都 一.概述 1.ELF全称Executable and Linkable Format,可执行连接格式,ELF格式的文 ...
- sql 语句的先后执行顺序
例:查询语句中select from where group by having order by的执行顺序 一般以为会按照逻辑思维执行,为: 查询中用到的关键词主要包含六个,并且他们的顺序依次为 ...
- svn 使用教程
一.什么是SVN SVN是Subversion的简称,是一个开放源代码的版本控制系统,相较于RCS.CVS,它采用了分支管理系统,它的设计目标就是取代CVS. 二.SVN的下载安装 下载地址:http ...
- SVN上传下载项目
1 本机安装svn服务器 1.1 创建新库 创建分支, Trunk:主干, Tags:分支节点 Branches:分支 比如说我们现在tomcat出了6.0以后已经定版了,但是还得继续开发呀,开 ...
- WIN10护眼色
参看文章:http://www.xitongcheng.com/jiaocheng/win10_article_10326.html WIN10:[HKEY_CURRENT_USER\Control ...
- hive视图
简化复杂的查询 员工好.姓名.月薪.年薪.在一个emp表中; 部门名称在dept的表中;并未年薪起了一个名字annlsal 查询视图 视图是一个虚表,是不存数据的