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]. 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 (≤) 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

 

题意:

给出n个数字,要求输出第一个只出现一次的数字,如果不存在,输出None.

题解:

用类似打表的方法,统计每个数出现的次数。按输出顺序遍历,当有次数为1的数时,输出,没有就输出None。

AC代码:

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<cstring>
using namespace std;
int a[];
int shu[];
int main()
{
int n;
cin>>n;
memset(a,,sizeof(a));
for(int i=;i<=n;i++){
cin>>shu[i];
a[shu[i]]++;
}
int f=;
for(int i=;i<=n;i++){
if(a[shu[i]]==){
cout<<shu[i];
f=;
break;
}
}
if(!f) cout<<"None";
return ;
}

PAT 甲级 1041 Be Unique (20 分)(简单,一遍过)的更多相关文章

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

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

  2. 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. ...

  3. PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642 题目描述: Being unique is so important to peo ...

  4. 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 ...

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

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

  6. PAT 甲级 1050 String Subtraction (20 分) (简单送分,getline(cin,s)的使用)

    1050 String Subtraction (20 分)   Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be t ...

  7. PAT 甲级 1042 Shuffling Machine (20 分)(简单题)

    1042 Shuffling Machine (20 分)   Shuffling is a procedure used to randomize a deck of playing cards. ...

  8. PAT 甲级 1035 Password (20 分)

    1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...

  9. PAT 甲级 1073 Scientific Notation (20 分) (根据科学计数法写出数)

    1073 Scientific Notation (20 分)   Scientific notation is the way that scientists easily handle very ...

随机推荐

  1. reverse函数的实现

    用递归的方法实现字符串的倒叙 #include <string.h> void reverse_my(char *a,int len) { int tmp;//中间值 if(len < ...

  2. 三、vue基础--表单绑定

    表单输入绑定:可以一起使用以下修饰符,都是在v-model里面使用的,有input,radio,textrea,select中都可以使用绑定 1.单选按钮,代码如下: <div id='app' ...

  3. fsLayuiPlugin入门使用

    简介 源码下载后,不能直接打开,必须运行在容器下,例如:nginx.tomcat.jetty等容器. 源码中默认配置了nginx容器,可以直接启动nginx访问. 本文主要介绍下载源码后的使用,避免在 ...

  4. 如何在C中以二进制格式打印十进制数?

    回答: #define CHAR_BITS  8  // size of character #define INT_BITS  ( sizeof(int) * CHAR_BITS) //bits i ...

  5. Spring Cloud Eureka 注册中心高可用机制

    一.Eureka 正常工作流程 Service 服务作为 Eureka Client 客户端需要在启动的时候就要向 Eureka Server 注册中心进行注册,并获取最新的服务列表数据. Eurek ...

  6. koa-compose 类库学习

    koa-compose 是koa 框架的根源的根源 ,是其实现洋葱包裹型中间件的基础 以下是koa2.X 版本所以依赖的compose 版本 ,其主要核心依赖于new Promise.resolve( ...

  7. Mysql查看所有表的数据量

    ##查看所有表信息 SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'pcms-zgh20190327' ##查看各个表数据量 ...

  8. 使用webuploader实现大文件断点续传

    IE的自带下载功能中没有断点续传功能,要实现断点续传功能,需要用到HTTP协议中鲜为人知的几个响应头和请求头. 一. 两个必要响应头Accept-Ranges.ETag 客户端每次提交下载请求时,服务 ...

  9. [vsftpd] ubuntu14.04 ansible剧本安装vsftpd流程及报错排查

    需求: 在ubuntu14.04机器上搭建ftp服务,ftp账号通过winscp软件登录后,仅可增删改/data/wwwroot目录. 一.安装步骤 1.apt 安装vsftpd apt-get in ...

  10. python 迷宫问题

    # -*- coding:utf- -*- from collections import deque # 引入队列 maze = [ [,,,,,,,,,], [,,,,,,,,,], [,,,,, ...