A1041
输入n个数,找出第一个只出现一次的数,输出它。
如果没有,输出none。
思路:
将输入的数值作为HashTable的数组下标即可。
#include<cstdio>
int a[], hashTable[]={};
int main(){
int n;
scanf("%d", &n);
for(int i=;i<n;i++){
scanf("%d",&a[i]);
hashTable[a[i]]++;
}
int ans=-;
for(int i=;i<n;i++){//遍历n即可
if(hashTable[a[i]]==){
ans=a[i];
break;
}
}
if(ans==-) printf("None");
else printf("%d\n", ans);
return ;
}
A1041的更多相关文章
- 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
Being unique is so important to people on Mars that even their lottery is designed in a unique way. ...
- 1041 Be Unique (20 分)
1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is desi ...
- 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& ...
随机推荐
- 使用Powershell 管理 Windows 2012 hyper-v复制
HyperV复制相关命令 Suspend-VMReplication Suspends replication of a virtual machine. 暂停复制虚拟机. Resume-VMRepl ...
- 【Leetcode】【Medium】Sqrt(x)
Implement int sqrt(int x). Compute and return the square root of x. 解题思路1,o(log(n)): 像这种从初始遍历查找匹配的任务 ...
- skype for business server 2015 报错“不可用:试图检查架构状态时发生故障,请确保能够访问Active Direcotry”
报错“不可用:试图检查架构状态时发生故障,请确保能够访问Active Direcotry” 遇到错误后就上网查询了下,有的人说用下面方法解决了 用域的administrator 登入就可以了(之前是用 ...
- Linux--sudo权限讲解
sudo简介:sudo是linux系统管理指令,是允许系统管理员让普通用户执行一些或者全部的root命令的一个工具,如halt,reboot,su等等.这样不仅减少了root用户的登录 和管理时间,同 ...
- HTTP常用状态码大全
HTTP状态码对照表 HTTP response codes 当浏览者访问一个网页时,浏览者的浏览器会向网页所在服务器发出请求.当浏览器接收并显示网页前,此网页所在的服务器会返回一个包含HTTP状态码 ...
- CentOS 6 网络yum源配置
# CentOS-Base.repo## The mirror system uses the connecting IP address of the client and the# update ...
- Oracle 时段负载情况
ALTER session SET nls_date_format='yyyy-mm-dd hh24:mi:ss'; SELECT * FROM ( SELECT A.INSTANCE_NUMBER ...
- redis持久化那些事(kēng)儿
这是一篇包含了介绍性质和吐槽性质的日志.主要介绍一下我学习redis持久化时候被坑的经历.redis的使用介绍现在没有打算写,因为比较多,以我如此懒的性格...好吧,还是有点这方面想法的,不过一篇博客 ...
- BZOJ2346:[Baltic 2011]Lamp(最短路)
Description 2255是一个傻X,他连自己家灯不亮了都不知道. 某天TZ大神路过他家,发现了这一情况, 于是TZ开始行侠仗义了. TZ发现是电路板的问题, 他打开了电路板,发现线路根本没有连 ...
- 「bzoj 3944: Sum」
题目 杜教筛板子了 #include<iostream> #include<cstring> #include<cstdio> #include<cmath& ...