hdu 4593 Robot
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=4593
Robot
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
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<map>
using std::map;
using std::min;
using std::find;
using std::pair;
using std::vector;
using std::multimap;
#define pb(e) push_back(e)
#define sz(c) (int)(c).size()
#define mp(a, b) make_pair(a, b)
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cls(arr, val) memset(arr, val, sizeof(arr))
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define tr(c, i) for(iter(c) i = (c).begin(); i != (c).end(); ++i)
const int N = 1010;
const int INF = 0x3f3f3f3f;
map<int, int> A;
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
int n, v, ans;;
while(~scanf("%d", &n)) {
A.clear();
rep(i, n + 1) {
scanf("%d", &v);
A[v]++;
if(2 == A[v]) ans = v;
}
printf("%d\n", ans);
}
return 0;
}
hdu 4593 Robot的更多相关文章
- HDU 4593 Robot (水题)
题意:有 n 个数,其中有两个数中相同的,让你找出这个数. 析:太简单了么,只要用数组下标记一下这个数的数量即可. 代码如下: #include <iostream> #include & ...
- HDOJ(HDU).1035 Robot Motion (DFS)
HDOJ(HDU).1035 Robot Motion [从零开始DFS(4)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双重DF ...
- HDU 4593 H - Robot 水题
H - RobotTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.act ...
- HDU 4576 Robot (概率DP)
暴力DP求解太卡时间了...........写挫一点就跪了 //hdu robot #include <cstdio> #include <iostream> #include ...
- HDU 5673 Robot 数学
Robot 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5673 Description There is a robot on the origi ...
- HDU 3150 Robot Roll Call – Cambot…Servo…Gypsy…Croooow(map)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3150 Problem Description Mystery Science Theater 3000 ...
- hdu 5673 Robot 卡特兰数+逆元
Robot Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem D ...
- hdu 1035 Robot Motion(模拟)
Problem Description A robot has been programmed to follow the instructions in its path. Instructions ...
- HDU 4576 Robot (概率 & 期望)
Robot Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)Total Sub ...
随机推荐
- 帕金森定律(Parkinson's Law)
帕金森定律(Parkinson's Law)是官僚主义或官僚主义现象的一种别称, 是由英国历史学家.政治学家西里尔·诺斯古德·帕金森(Cyril Northcote Parkinson)通过长期调查研 ...
- ASP.NET MVC 中使用 AjaxFileUpload 插件时,上传图片后不能显示(预览)
AjaxFileUpload 插件是一个很简洁很好用的上传文件的插件,可以实现异步上传功能,但是在 ASP.NET MVC中使用时,会出现上传图片后不能正确的显示的问题,经过仔细排查,终于找到原因,解 ...
- [Oracle] 中的Temporary tablespace的作用
临时表空间主要用途是在数据库进行排序运算[如创建索引.order by及group by.distinct.union/intersect/minus/.sort-merge及join.analyze ...
- [前端 1] 使用frameset框架构建网页基本布局
导读:在做项目的过程中,发现网页的一些地方是不变的,比如说顶部.底部.而变幻的内容就只是一部分.这个时候在想,这是每次都刷新一个界面呢,还是有别的快捷方法呢.然后就找到了frameset 这个东西.本 ...
- python urllib urllib2
区别 1) urllib2可以接受一个Request类的实例来设置URL请求的headers,urllib仅可以接受URL.这意味着,用urllib时不可以伪装User Agent字符串等. 2) u ...
- 分析器错误消息: 无法识别的属性“targetFramework”。请注意属性名称区分大小写。
转自:http://blog.sina.com.cn/s/blog_48964b12010157p0.html 配置错误说明: 在处理向该请求提供服务所需的配置文件时出错.请检查下面的特定错误详细信息 ...
- 解读CSS布局之-水平垂直居
对一个元素水平垂直居中,在我们的工作中是会经常遇到的,也是CSS布局中很重要的一部分,本文就来讲讲CSS水平垂直居中的一些方法.由于我们大搜车的日常工作中已经不再需要理会低版本IE,所以本文所贴出的方 ...
- Android IOS WebRTC 音视频开发总结(十五)-- 培训课程大纲
最近在给公司做内部培训,主要是关于即时通讯和移动视频通话,包括android与android,ios与ios,android与ios,以及手机与PC. ------------------------ ...
- Android WebRTC 音视频开发总结(五)-- webrtc开发原型
这些天基于WebRTC做了个 手机视频监控 的程序,分享出来,供想了解这方面内容的朋友参考. 这个程序最早是广州一家智能穿戴设备公司请我们做的(他们不需要底层源码,也不需要ios版本),之后我们在这个 ...
- 消息推送之GCM
利用GCM进行消息推送 原理 1.接收端向GCM注册registerid 2.发送端发消息给GCM服务器 这个过程需要三个参数: (1)API Key (2)registerid (3)传递的数据 3 ...