Problem 1001 Duplicate Pair
来源:互联网 发布:linux syslog配置 编辑:程序博客网 时间:2024/04/27 19:38
/*
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
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
*/
int sum[1000000]={0};int main(){long i,j,data;while(scanf("%ld",&i)!=EOF){for(j=0;j<i;j++){scanf("%ld",&data);sum[data]++;}for(j=0;j<1000000;j++){if(sum[j]==2){printf("%ld\n",j);}sum[j]=0;}}return 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
- 嵌入式linux-C学习之基础
- MiniGUI消息大全
- VC++ 2001 link错误 详解
- webgl learning 之体会总结
- excel行列互换excel行复制成列或者是excel列复制成行
- Problem 1001 Duplicate Pair
- 以原始套接字的方式 截获流经本机网卡的IP数据包
- 字符串处理(五)strstr和strtok
- POJ 3159 Candies
- 转载电脑小知识
- 使用报表时遇到的assembly引用错误
- Problem 1002 HangOver
- Python中的pprint和pformat简介
- BufferedImage()函数