FZU 1001 Duplicate Pair

来源:互联网 发布:聚宝盆时时彩软件 编辑:程序博客网 时间:2024/04/27 15:51

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

12


简单题

#include<stack>#include<queue>#include<cmath>#include<cstdio>#include<vector>#include<string>#include<cstdlib>#include<cstring>#include<algorithm>using namespace std;typedef long long LL;const int maxn=1000005;int T,n,m,f[maxn];int main(){while (~scanf("%d",&n)){for (int i=1;i<n;i++) f[i]=0;for (int i=1;i<=n;i++){scanf("%d",&m);f[m]++;if (f[m]==2) printf("%d\n",m);}}return 0;}


0 0
原创粉丝点击