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

AC:

#include <iostream>
#include <cmath>
#include <vector>
using namespace std;int n;
struct number
{int id, num;
}nn;
int mx = -1;
bool flag = false;
int arr[100000+5] = {0}, num;
vector<number> v;int main()
{scanf("%d", &n);for(int i = 0; i < n; i++){scanf("%d", &num);nn.id = i;nn.num = num;v.push_back(nn);arr[num] += 1;}for(int i = 0; i < v.size(); i++){if(arr[v[i].num] == 1){printf("%d", v[i].num);flag = true;break;}}if(!flag) printf("None");return 0;
}

刚开始打算用数字下标记录,忽略了顺序,后面改为vector,ok了

PAT甲级 -- 1041 Be Unique (20 分)相关推荐

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

  2. 【题意+解析】1041 Be Unique (20 分)_18行代码AC

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 Being unique is so important to people on Mars that even their lo ...

  3. PAT甲级 -- 1050 String Subtraction (20 分)

    Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking ...

  4. 【PAT甲级 LinkedHashMap】1041 Be Unique (20 分) Java、C++版

    题目 题目的意思是,找到第一个不重复的元素.输出它. 一开始用Java做,试了好多种方法都超时.后来换用C++通过了. AC题解:C++版 用Java尝试了各种方式,都是后两个测试点过不去,只好换C+ ...

  5. PAT甲级1041 Be Unique :[C++题解]模拟、哈希表

    文章目录 题目分析 题目链接 题目分析 来源:acwing 分析:统计次数,按序遍历,输出第一个出现次数为1的号码. ac代码 #include<bits/stdc++.h> using ...

  6. 【PAT甲级】11077 Kuchiguse (20 分) Java

    题目 Java题解(最后一个测试用例没通过) import java.io.BufferedReader; import java.io.IOException; import java.io.Inp ...

  7. PAT 甲级 1108 Finding Average (20 分)

    思路: 1.不是数字的位置只能在第一个且为负号,或者在字符串的倒数第一.二.三位置.或者不存在: 2.上面的方法也可以用sscanf或者sprintf进行判定: 3.数字要在规定区间内: 4.按.2f ...

  8. C++ PAT甲级 1050 String Subtraction (20分)

    Given two strings S​1 and S​2, S=S1−S​2is defined to be the remaining string aftertaking all the cha ...

  9. PAT甲级1100 Mars Numbers (20 分)题解

    \quad这个题稍微有点麻烦,需要分别处理数字转火星文和火星文转数字两种情况.不过数字最高两位,处理起来分别讨论即可.程序如下: #include <iostream> using nam ...

最新文章

  1. ubuntu phpinfo mysql_Ubuntu 16.04 apache+php+mysql环境搭建
  2. 「LibreOJ β Round #4」子集
  3. 区别:DOM Core 与 HTML-DOM
  4. 构造一个完美的分类系统
  5. python文件函数_python文件和文件夹复制函数
  6. 使用httpclient4.3.2来实现微信临时素材的上传
  7. 启动hadoop输入jps显示:程序 ‘jps‘ 已包含在下列软件包中: * openjdk-7-jdk * openjdk-6-jdk 请尝试:sudo apt-get install ~
  8. Cmake构建_设置全局编译选项
  9. 《Java大学教程》—第23章 Java网络编程
  10. java Swing+mysql实现的家庭收支管理系统(个人收支录入和查询)
  11. java汉诺塔递归算法
  12. 数学几何定理 与 13个基本不等式
  13. 蚂蚁金服 花呗借呗 招聘公告
  14. CSS 圆形图片,类似头像形状。
  15. lep开发笔记 -- 内存泄漏
  16. 一种基于蜂窝信令数据的数据驱动型OD矩阵构建的方法:以里昂地区(法国)作为研究...
  17. IDEA 项目打包成war包
  18. 2020数据分析师学习路径
  19. 如何重新设置苹果id密码_苹果ID密码忘记应该怎么做
  20. SpringBoot 使用Ffmpeg合并视频

热门文章

  1. LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
  2. STL算法学习-- 算法分类
  3. docker端口映射或启动容器时报错 driver failed programming external connectivity on endpoint
  4. 单元测试之带你搞懂Mockito使用
  5. 三流面试聊JDK,二流面试聊JVM,一流面试……
  6. [一]RabbitMQ-客户端源码之ConnectionFactory
  7. 测试:将手机摄像头用作网络摄像头的拍摄效果
  8. HEVC支持苹果HLS的几个关键问题
  9. 6.方法(go语言学习笔记)
  10. 鹅厂设计师是如何做设计的?