Problem 1001 Duplicate Pair
来源:互联网 发布:企鹅聊天软件 编辑:程序博客网 时间:2024/04/27 14:37
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 (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;}
0 0
- Problem 1001 Duplicate Pair
- Problem 1001 Duplicate Pair
- Problem 1001Duplicate Pair
- FZU 1001 Duplicate Pair
- fzu 1001 Duplicate Pair
- FZU 1001 Duplicate Pair
- FOJ-1001-Duplicate Pair
- Duplicate Pair
- Duplicate Pair
- FZU 1001 Duplicate Pair(简单题目)
- FOJ 1001 Duplicate Pair (位图算法)
- uva10245The Closest Pair Problem
- Duplicate Pair(异或操作)
- 10245 - The Closest Pair Problem
- 10245 - The Closest Pair Problem
- UVaOJ10245 - The Closest Pair Problem
- Uva10245-The Closest Pair Problem
- UVA10245 - The Closest Pair Problem
- java对cookie的操作
- 关于背景图片的知识
- MultiWindow实现窗口的层叠
- setOntouchListener和setOnKeyListener
- 【HTML】笔记
- Problem 1001 Duplicate Pair
- 创建一个简单的tomcat项目(配置虚拟主机)
- 【转载】移动web开发经验总结
- MySQL实现差集(Minus)和交集(Intersect)
- jdk1.8 ConcurrentHashMap实现相关内容
- 如何正确使用指针数组?(警醒)
- Android内存优化利器:MAT打开内存Bitmap(Windows版本)
- Problem 2191 完美的数字
- Eclipse中查看Java源代码的方法及一些注意事项