1041 Be Unique
1041 Be Unique (20 分)
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<bits/stdc++.h>
using namespace std;#define e exp(1)
#define p acos(-1)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define ll long long
#define ull unsigned long long
#define mem(a,b) memset(a,b,sizeof(a))
int gcd(int a,int b){return b?gcd(b,a%b):a;}int num[10005];
int a[100005];
int main()
{int n;scanf("%d",&n);for(int i=0; i<n; i++){scanf("%d",&a[i]);num[a[i]]++;}for(int i=0; i<n; i++){if(num[a[i]]==1){printf("%d\n",a[i]);return 0;}}printf("None\n");return 0;
}
1041 Be Unique相关推荐
- 【PAT (Advanced Level) Practice】1041 Be Unique (20 分)
1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is desi ...
- 1041 Be Unique
1.依旧是散列题,开一个整形的哈希数组bets[10010]来计数,最后数目为1的,也就是unique 2.注意,可能为1的不止一个,要输出第一个输入的unique,那么需要记录下读入的顺序,可以开辟 ...
- PAT甲级 -- 1041 Be Unique (20 分)
Being unique is so important to people on Mars that even their lottery is designed in a unique way. ...
- 【题意+解析】1041 Be Unique (20 分)_18行代码AC
立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 Being unique is so important to people on Mars that even their lo ...
- PAT甲级1041 Be Unique :[C++题解]模拟、哈希表
文章目录 题目分析 题目链接 题目分析 来源:acwing 分析:统计次数,按序遍历,输出第一个出现次数为1的号码. ac代码 #include<bits/stdc++.h> using ...
- 【PAT甲级 LinkedHashMap】1041 Be Unique (20 分) Java、C++版
题目 题目的意思是,找到第一个不重复的元素.输出它. 一开始用Java做,试了好多种方法都超时.后来换用C++通过了. AC题解:C++版 用Java尝试了各种方式,都是后两个测试点过不去,只好换C+ ...
- PAT甲级题目翻译+答案 AcWing(模拟)
1008 Elevator (20 分) 思路 :last可能等于cur,而无论是否相等,res都是+5的 #include <iostream>using namespace std;i ...
- 【最新合集】PAT甲级最优题解(题解+解析+代码)
以下每道题均是笔者多方对比后, 思考整理得到的最优代码,欢迎交流! 共同成长哇.可以和博主比拼一下谁刷的更快~ 欢迎收藏.欢迎来玩儿 PAT题解目录 题号 标题 题解 分类 使用算法 1001 A+B ...
- 算法笔记学习PAT甲级解题记录
算法笔记学习记录 2019.06.26 float&&double 推荐全部使用double,注意区分scanf("%lf",&double1);与prin ...
最新文章
- 2021年大数据Flink(三):​​​​​​​Flink安装部署 Local本地模式
- Spring Boot第二篇:Spring Boot配置文件详解
- 如何在分布式场景下生成全局唯一 ID ?
- brave浏览器_兼容Chrome 插件的Brave浏览器,带给你更快速的上网冲浪体验
- Juniper EX3400堆叠配置 + 链路捆绑配置
- 让图片算好高宽再显示
- 改进初学者的PID-修改整定参数
- 【BZOJ1096】仓库建设,斜率优化DP练习
- 敏捷开发一千零一问系列之十八:长期受制于强势客户怎么办?(下)
- vivado中交织模块_Adalm Pluto SDR主动学习模块让您拥有完善的无线电RF射频实验室...
- 快手视频大量下载无水印软件 怎样从快手下载无水印软件 说说如何在快手批量下载高清不含水印...
- JAVA 使用SSH/springboot集成 CXF框架发布Webservice
- 计算机的高级应用office,MS Office高级应用
- 《给忙碌者的天体物理学》pdf、mobi、epub下载
- 没有卑微的工作,只有卑微的工作态度
- Android 百度地图导航引擎初始化失败
- iOS/Mac OS X 汉字转拼音
- Kali Linux 安装Nvidia显卡驱动(二)CUDA, Pyrit and Cpyrit-cuda
- fuz 2159 WuYou
- Android屏幕适配之解决白屏启动的正确姿势