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

  1. 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

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

  4. 1041 Be Unique (20 分)

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

  5. PAT_A1041#Be Unique

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

  6. PAT甲级题解分类byZlc

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

随机推荐

  1. windows线程时间打印

    https://blog.csdn.net/xingcen/article/details/70084029

  2. Anaconda套件,精簡版miniconda

    雖然Anaconda會預先安裝豐富的套件模組,尤其是在數據科學領域方面,有非常豐富的寶藏, 大多範例或教學或許為了節省後續的麻煩,不解釋為什麼,直接就安裝Anaconda 就對了: 但是大部份的模組套 ...

  3. June 30th 2017 Week 26th Friday

    Love me little and love me long. 不求情意浓,但愿情意久. Some people say beautiful young people are the creatur ...

  4. C#图解教程读书笔记(第2章 C#编程概述)

    这章主要是一个对于C#程序的概括解释 和C/C++不同,不是用include声明引用的头文件,而是通过using的方式,声明引用的命名空间. 命名和C/C++类似,并且也是区分大小写的,这件事情在VB ...

  5. 【我所认知的BIOS】—> uEFI AHCI Driver(8) — Pci.Read()

    [我所认知的BIOS]-> uEFI AHCI Driver(8) - Pci.Read() LightSeed 6/19/2014 社会一直在变.不晓得是不是社会变的太苦开,而我没变所以我反而 ...

  6. UVa 11582 - Colossal Fibonacci Numbers!(数论)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  7. CF1063A Oh Those Palindromes

    嘟嘟嘟 只要将每一种字母放一块输出就行了. 证明1:比如 1 2 3 4 5 6,那么这个序列对答案的贡献分别是1和5,2和4 ,3和6……如果重新排列成x x x x o o,会发现对        ...

  8. 批量压缩文件夹到Zip文件

    实现效果: 实现代码:

  9. 使用Nginx 做负载均衡

    Nginx可以作为一个非常高效的负载均衡系统,通过分发HTTP请求到多个应用服务器来提高整个系统的吞吐量,性能和可用性. 负载均衡的算法/机制 下面是Nginx支持的机制 轮询机制 轮询算法 最少连接 ...

  10. ssm分页

    pom.xml配置文件中增加相关的插件. <dependency> <groupId>com.github.pagehelper</groupId> <art ...