A1041 Be Unique (20 分)
一、技术总结
- 这题在思考的时候遇见了,不知道怎么处理输入顺序问题,虽然有记录每个的次数,事后再反过来需要出现一次的且在第一次出现,
这时我们其实可以使用另一个数组用来存储输入顺序的字符,然后再用另一个数组记录出现的次数,这样就可以解决这个问题了。 - 如果使用cin出现运行超时的情况可以改用scanf,但是这个我运行的时候没有出现超时。
- 我把下列代码
int number[N];
改成
int number[10010];
然后提交出现段错误。不知道什么原因。。。。。
二、参考代码:
#include<iostream>
using namespace std;
int hashTable[10010];
int main(){
int N;
cin >> N;
int number[N];
int index = -1;
for(int i = 0; i < N; i++){
cin >> number[i];
hashTable[number[i]]++;
}
for(int i = 0; i < N; i++){
if(hashTable[number[i]] == 1){
index = number[i];
break;
}
}
if(index == -1){
cout << "None";
}else{
cout << index;
}
return 0;
}
A1041 Be Unique (20 分)的更多相关文章
- 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 (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642
PAT (Advanced Level) Practice 1041 Be Unique (20 分) 凌宸1642 题目描述: Being unique is so important to peo ...
- 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. ...
- 1041 Be Unique (20分)(水)
Being unique is so important to people on Mars that even their lottery is designed in a unique way. ...
- PAT 1041 Be Unique (20分)利用数组找出只出现一次的数字
题目 Being unique is so important to people on Mars that even their lottery is designed in a unique wa ...
- 【PAT甲级】1041 Be Unique (20 分)(多重集)
题意: 输入一个正整数N(<=1e5),接下来输入N个正整数.输出第一个独特的数(N个数中没有第二个和他相等的),如果没有这样的数就输出"None". AAAAAccepte ...
- 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 desi ...
- pat 1041 Be Unique(20 分)
1041 Be Unique(20 分) Being unique is so important to people on Mars that even their lottery is desig ...
随机推荐
- Debug 路漫漫-15:Python: NameError:name 'dataset' is not defined
在调试 <Outer Product-based Neural Collaborative Filtering>论文的源码(https://github.com/duxy-me/ConvN ...
- 【03】Nginx:location / root / alias
写在前面的话 前面我们谈了 nginx 基础的 WEB 服务配置以及定制我们的日志显示格式,接下来我能更加详细的说说 server 字段. location 字段 在 Server 中,如果我们只是一 ...
- Vue基础框架
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <!-- 设置语言为 ...
- QT+OpenGL(02)-- zlib库的编译
1.zlib库的下载 http://www.zlib.net/ zlib1211.zip 2.解压 3.进入 zlib1211\zlib-1.2.11\contrib\vstudio\vc14 目录 ...
- C 储存类与运算符
储存类 参考链接:https://www.runoob.com/cprogramming/c-storage-classes.html 存储类定义 C 程序中变量/函数的范围(可见性)和生命周期 au ...
- Python传入参数的几种方法
写在前面 Python唯一支持的参数传递方式是『共享传参』(call by sharing) 多数面向对象语言都采用这一模式,包括Ruby.Smalltalk和Java(Java的引用类型是这样,基本 ...
- Linux入门——注意事项
Linux入门——注意事项 摘要:本文主要说明了在使用Linux操作系统时,需要注意的问题. 严格区分大小写 和Windows不同,Linux是严格区分大小写的,包括文件名和目录名.命令.命令选项.配 ...
- 快速上手Mac效率神器Alfred以及Alfred常用操作
前言 Alfred,想必大家就算没用过也耳闻过.Alfred是一个让你可以丢掉鼠标的神器.很多读者可能之前认为Alfred的学习成本高,或者感觉它太复杂,而望之却步.其实Alfred并非高不可攀,本文 ...
- Objective-C学习——中文URL编码和解码
发现NSString类中有内置的方法可以实现.他们分别是: - (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncod ...
- vue全家桶项目应用断断续续的记录
一.引用axios插件报错 axios使用文档 Cannot read property 'protocol' of undefined 解决方法:在mainjs文件中把axios引入vue的原型函数 ...