https://pintia.cn/problem-sets/994805342720868352/problems/994805444361437184

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, 10^4^]. 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 (<=10^5^) 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:

  1. 7 5 31 5 88 67 88 17

Sample Output 1:

  1. 31

Sample Input 2:

  1. 5 888 666 666 888 888

Sample Output 2:

  1. None
  2.  
  3. 代码:
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int maxn = 1e5 + 10;
  5. int a[maxn], num[maxn];
  6.  
  7. int main() {
  8. int n;
  9. scanf("%d", &n);
  10. for(int i = 1; i <= n; i ++) {
  11. scanf("%d", &a[i]);
  12. num[a[i]] ++;
  13. }
  14.  
  15. int cnt = 0;
  16. for(int i = 1; i <= n; i ++) {
  17. if(num[a[i]] == 1) {
  18. printf("%d\n", a[i]);
  19. return 0;
  20. }
  21. if(num[a[i]] > 1)
  22. cnt ++;
  23. }
  24. if(cnt == n)
  25. printf("None\n");
  26. return 0;
  27. }

  

PAT 甲级 1041 Be Unique的更多相关文章

  1. PAT 甲级 1041 Be Unique (20 分)

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

  2. PAT 甲级 1041 Be Unique (20 分)(简单,一遍过)

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

  3. PAT甲级——1041 Be Unique

    1041 Be Unique Being unique is so important to people on Mars that even their lottery is designed in ...

  4. PAT 甲级 1041. Be Unique (20) 【STL】

    题目链接 https://www.patest.cn/contests/pat-a-practise/1041 思路 可以用 map 标记 每个数字的出现次数 然后最后再 遍历一遍 找到那个 第一个 ...

  5. PAT甲 1041. Be Unique (20) 2016-09-09 23:14 33人阅读 评论(0) 收藏

    1041. Be Unique (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Being uniqu ...

  6. 【PAT】1041. Be Unique (20)

    题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1041 题目描述: Being unique is so important to people ...

  7. PAT Advanced 1041 Be Unique (20 分)

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

  8. PAT甲级——A1041 Be Unique

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

  9. PAT Advanced 1041 Be Unique (20) [Hash散列]

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

随机推荐

  1. Java线程等待与唤醒

    class ThreadA extends Thread{ public ThreadA(String name) { super(name); } public void run() { synch ...

  2. 20155234 2016-2017-2 《Java程序设计》第2周学习总结

    20155234 2006-2007-2 <Java程序设计>第2周学习总结 教材学习内容总结 %%:表示字符串中的%. %d:以十进制整数格式输出 %f:以十进制浮点式格式输出 %e(% ...

  3. 20155310 2016-2017-2《Java程序设计》课程总结

    20155310 2016-2017-2<Java程序设计>课程总结 (按顺序)每周作业链接汇总 预备作业一:对师生关系的看法以及对专业的期望 预备作业二:Learning by doin ...

  4. day1 HTML - <head>

    1.html是什么? 超文本标记语言(Hypertext Markup Language,HTML) <!DOCTYPE html> <html lang="en" ...

  5. 【BZOJ3527】[ZJOI3527]力

    [BZOJ3527][ZJOI3527]力 题面 bzoj 洛谷 题解 易得 \[ E_i=\sum_{j<i}\frac{q_j}{(i-j)^2}-\sum_{j>i}\frac{q_ ...

  6. 探寻ASP.NET MVC鲜为人知的奥秘(3):寻找多语言的最佳实践方式

    如果你的网站需要被世界各地的人访问,访问者会使用各种不同的语言和文字书写习惯,那么创建一个支持多语言的网站就是十分必要的了,这一篇文章就讲述怎么快速合理的创建网站对多语言的支持.接下来通过一个实例来讲 ...

  7. SQL创建数据库、建表、填入内容

    --创建数据库 create database Information go --使用数据库 use Information go --创建表 create table Student ( Sno ) ...

  8. 180729-Quick-Task 动态脚本支持框架之任务动态加载

    Quick-Task 动态脚本支持框架之任务动态加载 前面几篇博文分别介绍了整个项目的基本架构,使用说明,以及整体框架的设计与实现初稿,接下来则进入更细节的实现篇,将整个工程中核心实现捞出来,从为什么 ...

  9. 随身Wifi+win7 搭建http代理 域名劫持 抓包 内容篡改实验环境

    需求来源: 1.平板或手机是个封闭系统无法给wifi设置代理 2.需要利用filllder进行抓包,内容篡改等实验 拥有硬件资源:PC机器 + 小米随身wifi 方案1: NtBind Dns + N ...

  10. 转 gerrit

    开发环境 https://blog.csdn.net/u013207966/article/details/79112740 先记录下我的开发环境以及要正确安装gerrit需要用到的工具: Redha ...