立志用最少的代码做最高效的表达


PAT甲级最优题解——>传送门


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:
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


题意:给一串数,输出第一个只出现过一次的数,若无则输出None

分析:定义队列存储数据,定义map数组查重。输出第一个不重复的即可。 若无则输出None


#include<bits/stdc++.h>
using namespace std;
int main( ) {int n; cin >> n;queue<int>q;map<int, int>m;while(n--) {int x; cin >> x; q.push(x); m[x]++;}while(!q.empty()) {if(m[q.front()] == 1) { cout << q.front() << '\n'; goto loop; }q.pop(); }cout << "None\n";loop :;return 0;
}

耗时:


求赞哦~

【题意+解析】1041 Be Unique (20 分)_18行代码AC相关推荐

  1. 1019 General Palindromic Number (20分)_18行代码AC

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 A number that will be the same when it is written forwards or bac ...

  2. 【最详细解析】1070 结绳 (25分)_18行代码AC

    立志用更少的代码做更高效的表达 Pat乙级最优化代码+题解+分析汇总-->传送门 给定一段一段的绳子,你需要把它们串成一条绳.每次串连的时候,是把两段绳子对折,再如下图所示套接在一起.这样得到的 ...

  3. 1081 Rational Sum (20 分)_22行代码AC

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 Given N rational numbers in the form numerator/denominator, you a ...

  4. 【题意+推导讲解】1031 Hello World for U (20 分)_15行代码AC

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 Given any string of N (≥5) characters, you are asked to form the ...

  5. 【题目解析】1015 Reversible Primes (20 分)_27行代码AC

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 A reversible prime in any number system is a prime whose "re ...

  6. 【最详细解析】1052 卖个萌 (20分)_28行代码AC

    立志用更少的代码做更高效的表达 Pat乙级最优化代码+题解+分析汇总-->传送门 萌萌哒表情符号通常由"手"."眼"."口"三个主要部 ...

  7. 【最简解法】1048 Find Coins (25 分)_18行代码AC

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 Eva loves to collect coins from all over the universe, including ...

  8. 1094 谷歌的招聘 (20分)_25行代码AC

    立志用最少的代码做更高效的表达 PAT乙级最优题解-->传送门 2004 年 7 月,谷歌在硅谷的 101 号公路边竖立了一块巨大的广告牌(如下图)用于招聘.内容超级简单,就是一个以 .com ...

  9. 【测试点分析】1067 试密码 (20分)_20行代码AC

    立志用更少的代码做更高效的表达 Pat乙级最优化代码+题解+分析汇总-->传送门 当你试图登录某个系统却忘了密码时,系统一般只会允许你尝试有限多次,当超出允许次数时,账号就会被锁死.本题就请你实 ...

最新文章

  1. 4-1 ADO.NET简介
  2. Netty:Java 领域网络编程的王者
  3. P2055 [ZJOI2009]假期的宿舍
  4. js获取URL请求参数与改变src
  5. 【视频】vue指令v-on绑定事件
  6. Your STATICFILES_DIRS setting is not a tuple or list
  7. uva 10602——Editor Nottoobad
  8. html知识笔记(一)——head和body标签
  9. [水煮 ASP.NET Web API2 方法论](1-1)在MVC 应用程序中添加 ASP.NET Web API
  10. spyder 怎么看函数定义_看漫画学C++035:自定义函数(1)
  11. fatal error C1010: unexpected end of file while looking for precompiled header directive
  12. modify sql_在SQL Server中使用JSON_MODIFY()修改JSON数据
  13. UINavigationController与UITabbarController的样式
  14. VINS-Fusion如何高效学习?
  15. EasyCHM制作教程
  16. 从社区角度看,区块链为什么这么火?它的未来在哪里?
  17. ios 字体 机打动效_24种打动朋友的方法
  18. Keychron K7 Pro 轻薄矮轴机械键盘开箱体验
  19. 网站收录查询,常用的2种网站收录查询方法
  20. 相机SD卡文件夹下所有文件损坏解决方法

热门文章

  1. WebSoket 的广泛应用
  2. 计算机网络 | IP协议相关技术与网络总结 :DNS、ICMP、DHCP、NAT/NAPT、通信流程
  3. C++ 基础 : 函数重载、引用、内联函数、auto、范围for循环
  4. 如何成为一名大厂的优秀员工?
  5. 你了解HTTPS工作原理吗?
  6. 运用贪心思想解决跳跃游戏
  7. 音视频技术开发周刊 | 194
  8. 玩转StyleGAN2模型:教你生成动漫人物
  9. 2019年的第三场LiveVideoStackCon有何不同?
  10. 讲述CCF-腾讯犀牛鸟基金项目成长故事