Ignatius and the Princess IV
来源:互联网 发布:食行天下软件 编辑:程序博客网 时间:2024/05/05 21:24
题意:给出一个奇数n,再给出n个数,求出现了至少(n+1)/2次的那个数。(反正不会出现两个以上)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1175
代码:
#include <cstdio>#include <cstring>const int maxn = 1e6;int vis[maxn];int main(){ int n; while (scanf("%d", &n) != EOF) { int a,k; memset(vis, 0, sizeof(vis)); for(int i=0; i<n; i++) { scanf("%d", &a); vis[a]++; if (vis[a] == (n+1)/2) k = a; } printf("%d\n", k); } return 0;}
0 0
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Ignatius and the Princess IV
- Android dump数据到文件
- Java Web项目中连接Access数据库
- SSD(Single Shot MultiBox Detector)理论学习
- go语言的模板
- 【android进阶篇】MVP+Retrofit+RxJava框架结合
- Ignatius and the Princess IV
- css 下拉框定位二三事
- JSP页面 小技巧
- Intent 隐示意图
- 欢迎使用CSDN-markdown编辑器
- 第二周《C语言及程序设计》实践项目26 利用switch语句解决问题
- kafka进击之路(一) —— 入门
- 浅谈SystemClock 和Thead的区别和联系
- 大数据系列修炼-Scala课程18