HDU-4593(水题)
Robot
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.
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)
There are no black lines between cases.
分析:直接统计每个数字出现的次数,为2的就输出就行了。
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=;
int h[maxn];
int main()
{
int n;
while(scanf("%d",&n)!=EOF){
int a;
memset(h,,sizeof(h));
for(int i=;i<=n;i++){
scanf("%d",&a);
h[a]++;
if(h[a]==) printf("%d\n",a);
}
}
return ;
}
HDU-4593(水题)的更多相关文章
- HDU-1042-N!(Java大法好 && HDU大数水题)
N! Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Subm ...
- HDU 5391 水题。
E - 5 Time Limit:1500MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- hdu 1544 水题
水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...
- HDU排序水题
1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...
- hdu 2710 水题
题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...
- Dijkstra算法---HDU 2544 水题(模板)
/* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...
- hdu 5162(水题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...
- hdu 3357 水题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...
- hdu 5038 水题 可是题意坑
http://acm.hdu.edu.cn/showproblem.php?pid=5038 就是求个众数 这个范围小 所以一个数组存是否存在的状态即可了 可是这句话真恶心 If not all ...
- hdu 5138(水题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5138 反着来. #include<iostream> #include<cstdi ...
随机推荐
- PorterDuff及Xfermode初识
图像合成,是将两幅退昂放在一起的动作,它使得我们能够同时看到两幅图像的特征. 我们可以首先在Canvas对象上绘制一个位图对象,然后再相同的Canvas对象上绘制第二个位图对象的方式来实现合成.不过这 ...
- android Button隐藏
两种方式: xml方式 和 java代码方式: 可见(visible) XML文件:android:visibility="visible" Java代码:view.setVisi ...
- 通过ip获取地理位置信息
http://ipinfo.io/developers 直接使用get请求 url: http://ipinfo.io/json 即可获得json数据
- Super Phyllis(穷举+搜索)
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2723 题意:给出一些字符串u,v,代表u-&g ...
- POJ_3068_Shortest_pair_of_paths_(最小费用流)
描述 http://poj.org/problem?id=3068 危险品:N个仓库由M条有向边连接,每条边都有一定费用.将两种危险品从0运到N-1,除了起点和终点外,危险品不能放在一起,也不能走相同 ...
- 新浪微博授权时出现"关注 *** 的微博"
基本设置完成后, 保证scope是 "all" 或 至少 包含 "follow_app_official_microblog". 测试时, 保证你的测试账号没有 ...
- Android-webView的loadUrl
1 //打开本包内asset目次下的test.html文件 wView.loadUrl(" file:///android_asset/test.html "); 2 //打开本地 ...
- Makefile第一讲:一个简单的Makefile
摘要 假定你对linux已经比较的熟悉,假定你编程已经稍有经验,本文不会对文章作出太多基础性解释,看不懂莫怪,只当作给学习的朋友一个引导思路,我也是一个初学者,边学边写,将学会的教给大家,文章有错误之 ...
- Yii PHP 框架分析(三)
作者:wdy http://hi.baidu.com/delphiss/blog/item/357663d152c0aa85a1ec9c44.html Yii应用的入口脚本引用出了Yii类,Yii类的 ...
- PC-网络教程之宽带小型组网方案
由于某些家庭或小型局域网用户的各种需求和设备不同,所以继续写出几个组网方案让大家参考参考.如有错误之处,欢迎大家多多指点. 1,用网桥实现增加接入点(比如你有5台机子要上网,而你的小型路由只有4个接口 ...