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 ...
随机推荐
- 微服务之Sping Cloud
版本说明 Finchley SR2 价值简要 微服务之间是松耦合,跨不同业务部门,提供非常充分的灵活性,加快项目开发完成效率,方便组件化独立可扩展性及复用. 微服务应用结构表现 组件简要 1. Eur ...
- Jmeter-使用Stepping Thread Group插件来设置负载场景
前言: 什么是实际的性能测试???1)思考时间:用户在做不同操作之间有时间停顿,或者延迟,思考时间就是模拟用户的操作过程中的停顿的间.2)步伐,速度:主要包括,大量用户进来的时间和退出时间,控制迭代之 ...
- 小程序encryptedData
准备知识: Base64编解码 AES算法.填充模式.偏移向量 session_key会话密钥,以及怎么存储和获取 以上3点对于理解解密流程非常重要. 根据官方文档,我梳理了大致的解密流程,如下: 小 ...
- 《linux内核设计与实现》第十八章
第十八章 调试 调试工作艰难是内核级开发区别于用户级开发的一个显著特点. 一.准备开始 1.内和调试需要什么 一个bug(大部分bug通常都不是行为可靠而且定义明确的) 一个藏匿bug的内核版本(知道 ...
- 20145221 《Java程序设计》实验报告四:Android开发基础
20145221 <Java程序设计>实验报告四:Android开发基础 实验要求 基于Android Studio开发简单的Android应用并部署测试; 了解Android组件.布局管 ...
- <构建之法>13——17章的读后感
第13章:软件测试 问题:对于这么多种的测试方法,怎么才能最有效的选取? 第14章:质量保证 问题:很多工程师都把大多数时间花在软件质量上.一成不变是无法创新的.如何在保证质量的情况下,又得到创新呢? ...
- 使用Java+Kotlin双语言的LeetCode刷题之路(二)
BasedLeetCode LeetCode learning records based on Java,Kotlin,Python...Github 地址 序号对应 LeetCode 中题目序号 ...
- 8-Python3从入门到实战—基础之数据类型(集合-Sets)
Python从入门到实战系列--目录 集合的定义 集合(set)和字典类似,也是一组key的集合,但不存储value:由于key不能重复,所以,在set中,没有重复的key. 创建一个set,需要提供 ...
- Golang 函数
创建函数 package main import "fmt" //有参数,有返回值 func demo(a int, s string) (int, string) { retur ...
- Java抓任意网页标题乱码jsoup解决方案一例
同事用Java做了一个抓取任意网页的标题的功能,由于任意网页的HTML的head中meta中指定的charset五花八门,比如常用的utf-8,gbk,gb2312. 自己写代码处理,短时间内,发现各 ...