FOJ_1001_Duplicate Pair
来源:互联网 发布:2017成都凶宅数据库 编辑:程序博客网 时间:2024/05/01 05:37
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
21 141 2 3 2
Sample Output
12
#include<stdio.h>
int main()
{
long long int sum,num;
long int n,a,cfs,i;
while(scanf("%ld",&n)!=EOF)
{
num=0;
sum=0;
for(i=1;i<n;i++)
sum+=i;
for(i=0;i<n;i++)
{
scanf("%ld",&a);
num+=a;
}
cfs=num-sum;
printf("%ld/n",cfs);
}
return 0;
}
- FOJ_1001_Duplicate Pair
- pair
- pair
- Pair
- Pair
- pair
- Code-Pair
- pair make_pair
- pair & make_pair
- C++ pair
- interviewstreet pair
- pair make_pair
- STL Pair
- C++ Pair
- pair用法
- pair(STL)
- android Pair
- c++ pair
- 成功的培养基
- FOJ 1000 PKU 1000 FJNU 1000 A+B Problem
- Google Code jam 编程挑战赛 赛后感
- 第一篇关于专业知识的文章
- MSSQL 2000安装 图解
- FOJ_1001_Duplicate Pair
- ddd
- "您试图在此 Web 服务器上访问的 Web 应用程序当前不可用"IIS解决方法
- 熊猫烧香核心源代码
- 突然........
- FOJ_1002_HangOver
- 时间概念 — 24时区、GMT、UTC的意涵
- 黑客黑了一百万台电脑 赢得一份工作
- 软件工程硕士:未来十大金领职业之一