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的更多相关文章

  1. PAT甲级——A1041 Be Unique

    Being unique is so important to people on Mars that even their lottery is designed in a unique way. ...

  2. A1041 Be Unique (20 分)

    一.技术总结 这题在思考的时候遇见了,不知道怎么处理输入顺序问题,虽然有记录每个的次数,事后再反过来需要出现一次的且在第一次出现, 这时我们其实可以使用另一个数组用来存储输入顺序的字符,然后再用另一个 ...

  3. PAT_A1041#Be Unique

    Source: PAT A1041 Be Unique (20 分) Description: Being unique is so important to people on Mars that ...

  4. PAT甲级题解分类byZlc

    专题一  字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...

  5. 1041 Be Unique (20 分)

    1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is desi ...

  6. [LeetCode] Unique Substrings in Wraparound String 封装字符串中的独特子字符串

    Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...

  7. [LeetCode] Minimum Unique Word Abbreviation 最短的独一无二的单词缩写

    A string such as "word" contains the following abbreviations: ["word", "1or ...

  8. [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  9. [LeetCode] Unique Word Abbreviation 独特的单词缩写

    An abbreviation of a word follows the form <first letter><number><last letter>. Be ...

随机推荐

  1. dpkg:错误:正在解析文件 '/var/lib/dpkg/updates/0014' 第 0 行附近:在字段名 #padding 中有换行符问题的解决方法

    解决方案如下: sudo rm /var/lib/dpkg/updates/* sudo apt-get update python@ubuntu:~/Desktop/_Welcome_.jpg.ex ...

  2. Docker阿里云镜像加速

    登录阿里云docker registry sudo docker login --username=zhangsan@163.com registry.cn-hangzhou.aliyuncs.com ...

  3. Redis Cluster日常操作命令梳理

    在之前的一篇文章已经介绍了Redis Cluster及其部署,下面说下Redis Cluster日常操作命令: 一.以下命令是Redis Cluster集群所独有的,执行下面命令需要先登录redis: ...

  4. linux上启动tomcat远程不能访问

    linux上关闭防火墙同样访问不了,执行iptables -f即可. 你试一试这个“iptables -F”然后再访问,如果能够访问了,那么需要执行“firewall-cmd --add-port=8 ...

  5. Command Analyze failed with a nonzero exit code

    在运行RN项目的时候,报 Command Analyze failed with a nonzero exit code ,试着将build System 修改下

  6. Practice2 结对子之“小学四则运算”

    开发环境:Eclipse,js,css,html 程序完成的方向: 1.可以出表达式里含有负整数(负整数最小不小于-100)的题目,且负数需要带括号,用户输入的结果不用带括号.如: 2*(-4) = ...

  7. 无符号整型 unsigned int、unsigned long、usigned long long、size_t 比较和格式控制

    位数比较 由于数据的长度和平台相关,所以基于 64 位系统比较. Windows Linux unsigned int 32 bits/4294967295 32 bits unsigned long ...

  8. Running kubernetes on windows

    docker-for-desktop minikube GKE cluster(?) docker-for-desktop https://docs.docker.com/docker-for-win ...

  9. Comparison of Static Code Analysis Tools for Java

    http://www.sw-engineering-candies.com/blog-1/comparison-of-findbugs-pmd-and-checkstyle https://stack ...

  10. JMeter性能测试基础 (4)-使用JMeter录制测试脚本

    在进行压力测试时,由于很多web页面包含了Ajax异步请求等内容,为模拟用户真实输入,除了对html的访问外,还需要将其它的访问考虑入内,这时最好的办法就是对实际访问过程中的所有请求进行录制. 例如, ...