Duplicate Pair
Time Limit: 1000 mSec Memory Limit : 65536 KB
Problem Description
An array of length n, with address from 1 to n inclusive, contains entries from the set {1,2,…,n-1} and there’s exactly two elements with the same value. Your task is to find out the value.
Input
Input contains several cases.
Each case includes a number n (n>1&&n<=10^6), which is followed by n integers.
The input is ended up with the end of file.
Output
Your must output the value for each case, one per line.
Sample Input
2
1 1
4
1 2 3 2
Sample Output
1
2
#include"stdio.h"
#include"string.h"
int main()
{int n;const int maxn=1e6;int ai[maxn+7];int bi[maxn+7];while(scanf("%d",&n)==1){memset(bi,0,sizeof(bi));for(int i=0;i<n;i++){scanf("%d",&ai[i]);bi[ai[i]]++;}for(int i=1;i<n;i++){if(bi[i]==2){printf("%d\n",i);break;}}}return 0;
}
题意: 输入n个数 这n个数包括1到n-1 所以必然有一个数出现两次 找出这个数
Duplicate Pair相关推荐
- gensim下载时出现找不到information.json的问题
主动在C:\Users\18360\gensim-data中添加information.json文件 {"corpora": {"semeval-2016-2017-ta ...
- unable to read local cache ‘C:\\Users\\admin/gensim-data\\information.json‘ during fallback 解决办法
1.打开一个新的notepad++页面,复制下面这段话 { "corpora": {"semeval-2016-2017-task3-subtaskBC": { ...
- unable to read local cache ‘C:\\Users\\kingS/gensim-data\\information.json‘ during fallback, connec
1.复制该段代码 {"corpora": {"semeval-2016-2017-task3-subtaskBC": {"num_records&qu ...
- unable to read local cache ‘C:\\Users\\../gensim-data\\information.json‘ during fallback, connect to
报错: 报错位置: unable to read local cache 'C:\\Users\\....../gensim-data\\information.json' durin ...
- TimesTen 数据库复制学习:4. 定义Active Standby Pair复制策略
master数据库状态 可以使用ttRepStateGet 得到数据库的复制状态/角色 ACTIVE - active master,主库,可读写 STANDBY - active standby,备 ...
- C++:vector容器中使用pair该如何访问成员
(显然,vector 的索引从 0 开始,这和普通数组一样.通过使用索引,总是可以访问到 vector 容器中现有的元素.) 如果是简单的访问vector里边的成员的话,是这样的: #include ...
- HDU - 5877 Weak Pair 2016 ACM/ICPC 大连网络赛 J题 dfs+树状数组+离散化
题目链接 You are given a rootedrooted tree of NN nodes, labeled from 1 to NN. To the iith node a non-neg ...
- LeetCode刷题记录2——217. Contains Duplicate(easy)
LeetCode刷题记录2--217. Contains Duplicate(easy) 目录 LeetCode刷题记录2--217. Contains Duplicate(easy) 题目 语言 思 ...
- C++中标准模板库std::pair的实现
以下用C++实现了标准模板库中的std::pair实现,参考了 cplusplus 和 vs2013中的utility文件. 关于std::pair的介绍和用法可以参考: https://blog.c ...
最新文章
- WebService 学习之路(一):了解并使用webService
- SQL(Oracle)日常使用与不常使用函数的汇总
- Spring MVC上下文父子容器
- ASCII码排序(C++)
- ad电阻原理图_【雕爷学编程】Arduino动手做(2)---光敏电阻模块
- 【版本发布】JEECG 3.6.2 移动能力版发布,快速开发平台
- GDAL源码剖析(九)之GDAL体系架构
- cbv、resful、APIView和序列化组件
- Mathematics Base - 期望、方差、协方差、相关系数总结
- IDEA 2020.3 更新了,机器学习都整上了
- 修改Gravatar生成的默认头像
- 软件测试性能测试报告完整版,性能测试报告模板
- python柱状图加百分比_python matplotlib 为柱状图添加百分比
- 2008年国外最漂亮的50个网站欣赏
- 横向时间轴插件 html5,jQuery横向滚动时间轴插件
- php 微信 防刷票,细数那些防止微信刷票的设置
- 对象、继承、封装、多态、抽象类的组合应用:编写工资系统,实现不同类型员工(多态)的按月发放工资。如果当月出现某个Employee对象的生日,则将在该雇员的工资上增加100元发给他。
- 我怀疑京东神秘部门Y,悟出智能供应链真相了
- 网络工程师2017上半年软考上午试题
- 用友nc65 uap开发找产品功能源代码