HDU 4593 Robot
来源:互联网 发布:美联储资产负债表数据 编辑:程序博客网 时间:2024/05/23 16:12
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.
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 <= 10 3)
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 <= 10 3)
Output
Each case, output a line with the reused number.
There are no black lines between cases.
There are no black lines between cases.
Sample Input
21 2 111 1
Sample Output
11
题目大意:给出n+1个数,找到重复出现的数。
解题思路:水题,n最大不过1000,开个数组标记一下即可。
#include<iostream>using namespace std;int main(){ int i,j,t; while(cin>>t) { int a[1001]; int b[1001]={0}; for(i=0;i<=t;i++) { cin>>a[i]; b[a[i]]++; } for(j=0;j<=t;j++) if(b[j]==2) { cout<<j<<endl; break; } } return 0;}
0 0
- HDU 4593 Robot
- HDU 4593 Robot
- HDU 4593 Robot
- hdu 4593 Robot
- HDU 4593 Robot
- HDU 4593 Robot
- hdu 4593 Robot(签到题)
- Robot HDU
- hdu 1035 Robot Motion
- HDU 1035 Robot Motion
- HDU-1035 ROBOT NOTION
- hdu 1035 Robot Motion
- hdu 1035 Robot Motion
- hdu 4375 Programmable Robot
- hdu~4166~Robot Navigation
- hdu 1035 Robot Motion
- HDU 1035 Robot Motion
- hdu 1035 Robot Motion
- v4l2 video设备支持功能查询
- <转>extern的详解
- ENetwork Chapter 3 - CCNA Exploration (Version 4.0)
- typedef
- 环境表
- HDU 4593 Robot
- QT重装后出现的问题
- Linux是什么?
- Android开发ListView之BaseExpandableListAdapter
- 笑傲面试和简历编写
- ZOJ 3600 Taxi Fare
- Nginx
- 好看的常用背景色RGB
- JSON解析与序列化