PAT甲级——1041 Be Unique
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 <iostream>
#include <string>
using namespace std;
int main(void)
{
int a[100001] = {0};
int b[100001] = {0};//用来区别该数字是否重复出现
int n,flag=0;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> a[i];
b[a[i]]++;
}
for (int i = 0; i < n; i++)
{
if (b[a[i]] == 1)
{
cout << a[i] << endl;
return 0;
}
}
if (flag == 0)
cout << "None" << endl;
return 0;
}
PAT甲级——1041 Be Unique的更多相关文章
- PAT 甲级 1041 Be Unique (20 分)
1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is desi ...
- PAT 甲级 1041 Be Unique (20 分)(简单,一遍过)
1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is de ...
- PAT 甲级 1041 Be Unique
https://pintia.cn/problem-sets/994805342720868352/problems/994805444361437184 Being unique is so imp ...
- PAT 甲级 1041. Be Unique (20) 【STL】
题目链接 https://www.patest.cn/contests/pat-a-practise/1041 思路 可以用 map 标记 每个数字的出现次数 然后最后再 遍历一遍 找到那个 第一个 ...
- 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 ...
- 【PAT】1041. Be Unique (20)
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1041 题目描述: Being unique is so important to people ...
- 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. ...
- PAT甲级——A1041 Be Unique
Being unique is so important to people on Mars that even their lottery is designed in a unique way. ...
- 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 ...
随机推荐
- swiper用axios异步请求后 循环失效
解决方案 使用ajax动态获取数据 当数据还没有收到的时候,swiper组件收到的是跟组件data传过来的空数组,会造成渲染问题 这个时候可以给swiper组件 设置一个 v-if='list.l ...
- Python Learning Day3
爬虫练习 说是练习,实际是尝试了一些还没有具体了解的方式吧hhhhh' 基于urllib实现 import urllib.request import re url="https://www ...
- springBoot中的邮件发送
1. 添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId> ...
- UVALive 6491 You win! 状态DP
这个题目上周的对抗赛的,美国2013区域赛的题目,上次比赛真惨,就做出一道题,最多的也只做出两道,当时想把这题做出来,一直TLE. 这个题目用挂在Hunnu OJ的数据可以过,但UVALive上死活过 ...
- POJ 1185 状态DP
这个题目是个挺难表示的状态DP,因为不但要考虑上下还要考虑左右,在DP里面就没有什么下了咯,但也至少除了考虑左右还要考虑上 所以先枚举出在同一行满足条件的状态 即 某状态 若 s&(s< ...
- 2020.2.21一些python总结
#字符串前面加r可以防止字符串转义 \也可以防止字符串转义#三引号可以实现输入多行文本#range(start,end,step)#列表 append添加一个元素到末尾 extend 添加一个素组到末 ...
- @JsonIgnoreProperties 不生效
定义类如下, import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annota ...
- Luogu P3031 高于中位数
定义序列\(x_i = f([H_i >=x])\;\;\;\;其中f(0) = -1,f(1) = 1\),那么区间[i,j]满足条件当且仅当sum_j-sum_{i-1} > 0,即s ...
- vim 马哥
VIM编辑器 编辑模式 默认 输入模式 i 末行模式 : vim +# file #打开文件后直接跳到第#行 vim + file 直接跳到尾行 vim +/关键字 跳转到 ...
- nouveau :failed to create kernel chanel,-22
一:錯誤描述:今天在重啓 Ubuntu 的過程中,出現下圖的 grub 選項,系統重啓/開機之後出現以下畫面,然後選擇 Ubuntu 之後黑屏,提示錯誤:nouveau :failed to crea ...