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 ...
随机推荐
- [转]response.getWriter().write()与out.print()的区别
原文地址:http://blog.csdn.net/javaloveiphone/article/details/8133772 1.首先介绍write()和print()方法的区别: (1).w ...
- 关于mysql数据库行级锁的使用(一)
项目上一个业务需要对某条数据库记录加锁,使用的是mysql数据库 因此做了一个关于mysql数据库行级锁的例子做测试 package com.robert.RedisTest; import java ...
- Jenkins_获取源码编译并启动服务(一)
一.安装Jenkins插件(可以手动安装,使用推荐安装容易卡死) 系统管理-->插件管理-->可选插件 Folders Plugin OWASP Markup Formatter Plug ...
- Laplacian算子
多元函数的二阶导数又称为Laplacian算子: \[ \triangledown f(x, y) = \frac {\partial^2 f}{\partial x^2} + \frac {\par ...
- hdu2888 二维RMQ
Check Corners Time Limit: 2000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- 改变Yii2的默认路由
修改配置文件 return [ 'name'=>'AA后台', 'id' => 'app-backend', 'defaultRoute'=>'shop/index',//路由 …… ...
- xml解析工具-jdom
前言:近期接触SSH框架的时候,经常得配置一下xml文件:今天闲来没事就挖挖xml解析的原理供大伙儿分享.本文主要通过一个简单的例子解析一个xml文件.明白其中缘由之后,大家想定义自己的xml也绝非难 ...
- 用 perl 统计 fasta 文件序列的总长
#!/usr/bin/perl -w use strict; die "Usage: $0 <file>\n" unless (@ARGV == 1); my $lin ...
- Leetcode 98. Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as ...
- CruiseControl.NET/CCNET安装包下载
链接:http://pan.baidu.com/s/1bHgeCI 密码:d7q1