POJ 2388 Who's in the Middle(水~奇数个数排序求中位数)
题目链接:http://poj.org/problem?id=2388
题目大意:
奇数个数排序求中位数
解题思路:看代码吧!
AC Code:
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int na[n+];
for(int i=; i<n; i++)
scanf("%d",&na[i]);
sort(na,na+n);
printf("%d\n",na[n/]);
}
return ;
}
POJ 2388 Who's in the Middle(水~奇数个数排序求中位数)的更多相关文章
- poj 2388 Who's in the Middle
点击打开链接 Who's in the Middle Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 28324 Acce ...
- POJ 2388 Who's in the Middle (快速选择算法:O(N)求数列第K大)
[题意]求数列中间项. ---这里可以扩展到数列第K项. 第一次做的时候直接排序水过了= =--这一次回头来学O(N)的快速选择算法. 快速选择算法基于快速排序的过程,每个阶段我们选择一个数为基准,并 ...
- poj 2388 Who's in the Middle(快速排序求中位数)
一.Description FJ is surveying his herd to find the most average cow. He wants to know how much milk ...
- POJ 2388&&2299
排序(水题)专题,毕竟如果只排序不进行任何操作都是极其简单的. 事实上,排序算法十分常用,在各类高级的算法中往往扮演着一个辅助的部分. 它看上去很普通,但实际的作用却很大.许多算法在失去排序后将会无法 ...
- poj 2388 insert sorting
/** \brief poj 2388 insert sorting 2015 6 12 * * \param * \param * \return * */ #include <iostrea ...
- POJ.2739 Sum of Consecutive Prime Numbers(水)
POJ.2739 Sum of Consecutive Prime Numbers(水) 代码总览 #include <cstdio> #include <cstring> # ...
- 蓝桥杯 算法训练 Torry的困惑(基本型)(水题,筛法求素数)
算法训练 Torry的困惑(基本型) 时间限制:1.0s 内存限制:512.0MB 问题描述 Torry从小喜爱数学.一天,老师告诉他,像2.3.5.7……这样的数叫做质数.Torry突 ...
- POJ 3415 不小于k的公共子串的个数
Common Substrings Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 9248 Accepted: 3071 ...
- POJ 2388:Who's in the Middle
Who's in the Middle Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 31015 Accepted: 1 ...
随机推荐
- 【CodeVS 1218】【NOIP 2012】疫情控制
http://codevs.cn/problem/1218/ 比较显然的倍增,但是对于跨过根需要很多讨论,总体思路是贪心. 写了一上午,不想再说什么了 #include<cstdio> # ...
- 网络流最小割 POJ 3469
题意 2个CPU n个任务 给出在第一个 第二个运行时的花费 m 个 a b 不在同一个CPU运行的额外花费 建图 源点 -> n -> 汇点 权 a1 ...
- [转]REST简介
转自:http://www.cnblogs.com/loveis715/p/4669091.html 一说到REST,我想大家的第一反应就是“啊,就是那种前后台通信方式.”但是在要求详细讲述它所提出的 ...
- 新手该学习Python2.x版本还是3.x版本
如果你是一个初学者,或者你以前接触过其他的编程语言,你可能不知道,在开始学习python的时候都会遇到一个比较让人很头疼的问题:版本问题!!是学习python2 还是学习 python3 ?这是非常让 ...
- 浅谈malloc()与free()
malloc()与free() l 函数原型 malloc函数的函数原型为:void* malloc(unsigned int size),它根据参数指定的尺寸来分配内存块,并且返回一个void型指 ...
- OPENGL的入门第一个程序——Hello World
#include "stdafx.h" #include<GL\glut.h> void Init() { glClearColor(0.0f,0.0f,0.0f,0. ...
- 使用触发器实现记录oracle用户登录失败信息到alert.log日志文件
前面我们说了用oracle自带的审计功能可以实现记录用户登录失败日志到数据表中(链接:http://www.54ok.cn/6778.html).今天我们来分享一下如何把用户登录失败信息记录到aler ...
- Android studio:Groovy 与 Gradle 基础【三】
转载:http://www.apkbus.com/forum.php?mod=viewthread&tid=255064&extra=page%3D2%26filter%3Dautho ...
- 【caffe】基本数据结构blob
@tags: caffe blob blob是caffe中的基本数据结构,简单理解就是一个"4维数组".但是,这个4维数组有什么意义? BTW,TensorFlow这款google ...
- JQuery冲突问题,以及含有jquery的框架与jquery冲突
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...