2015
09-17

# HDU 4593-Robot[解题报告]HOJ

Robot
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 246    Accepted Submission(s): 185

Problem Description
A robot is a mechanical or virtual artificial agent, usually an electro-mechanical machine that is guided by a computer program or electronic circuitry. Robots can be autonomous or semi-autonomous and range from humanoids such as Honda’s Advanced Step in Innovative
Mobility (ASIMO) and Tosy’s TOSY Ping Pong Playing Robot (TOPIO) to industrial robots, collectively programmed ‘swarm’ robots, and even microscopic nano robots. By mimicking a lifelike appearance or automating movements, a robot may convey a sense of intelligence
or thought of its own.
Robots have replaced humans in the assistance of performing those repetitive and dangerous tasks which humans prefer not to do, or are unable to do due to size limitations, or even those such as in outer space or at the bottom of the sea where humans could
not survive the extreme environments.
After many years, robots have become very intellective and popular. Glad Corporation is a big company that produces service robots. In order to guarantee the safety of production, each robot has an unique number (each number is selected from 1 to N and will
be recorded when the robot is produced).
But one day we found that N+1 robots have been produced in the range of 1 to N , that’s to say one number has been used for 2 times. Now the president of Glad Corporation hopes to find the reused number as soon as possible.

Input
Multiple cases, end with EOF.
In each case, The first line has one number N, which represents the maximum number. The next line has N +1 numbers. (All numbers are between 1 to N, and only two of them are the same.) (1 <= N <= 103)

Output
Each case, output a line with the reused number.
There are no black lines between cases.

Sample Input
2
1 2 1
1
1 1

Sample Output
1
1

Source
2013 ACM-ICPC南京赛区全国邀请赛——题目重现

#include<stdio.h>
#include<string.h>
int a[2000],b[2000];
int main()
{
int i,j,n,m;
while(scanf("%d",&n)!=EOF)
{
memset(b,0,sizeof(b));
for(i=0;i<n+1;i++)
{
scanf("%d",&a[i]);
j=a[i];
b[j]++;
if(b[j]==2)
m=j;
}
printf("%d\n",m);
}
return 0;
}