PAT甲级1041. Be Unique (20)
来源:互联网 发布:mysql 存储emoji 编辑:程序博客网 时间:2024/06/05 07:15
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 <vector>using namespace std;const int MAX=100000+10;int cnt[MAX]={0};int main(){ int N; scanf("%d",&N); vector<int> V(N); for(int i=0;i<N;i++){ scanf("%d",&V[i]); cnt[V[i]]++; } int flag=0; for(int i=0;i<N;i++){ if(cnt[V[i]]==1) { printf("%d",V[i]); flag=1; break; } } if(!flag) printf("None"); return 0;}
- 【PAT甲级】1041. Be Unique (20)
- 1041. Be Unique (20) PAT 甲级
- PAT(甲级)1041. Be Unique (20)
- PAT甲级练习1041. Be Unique (20)
- PAT甲级1041. Be Unique (20)
- PAT 甲级 1041. Be Unique (20)
- PAT甲级 1041. Be Unique (20)
- 1041. Be Unique (20)-PAT甲级真题(Hash散列)
- 【PAT】1041. Be Unique (20)
- 1041. Be Unique (20)-PAT
- PAT 1041. Be Unique (20)
- PAT 1041. Be Unique (20)
- pat 1041. Be Unique (20)
- PAT 1041. Be Unique (20)
- PAT 1041. Be Unique (20)
- PAT 1041. Be Unique (20)
- PAT 1041. Be Unique
- PAT 1041. Be Unique
- 【LeetCode 358】 Rearrange String k Distance Apart
- ES6 正则扩展
- maven+spring 遇到No mapping found for HTTP request with URI的问题
- Paragon ntfs for mac 15与Tuxera ntfs for mac2016.1哪个更好用
- leecode 解题总结:319. Bulb Switcher
- PAT甲级1041. Be Unique (20)
- SQL中create table语句创建数据表
- el表达式输出集合,集合中有对象,对象里还有对象属性
- log4j2基础篇(1)
- 用matlab批量新建和删除文件夹
- 使用NativeLibCompression极致压缩APK文件大小
- 分享 library 到 bintray jcenter代码库
- 别了——我的2016!
- lx001乘法表