(poj)Sequence Median
Description
Your task is to write program to find the median of given sequence.
Input
Output
Sample Input
4
3
6
4
5
Sample Output
4.5
Hint
#include<iostream>
#include <cstdio>
#include<algorithm>
using namespace std;
int main()
{
int nums[];
int n;
int i;
while(scanf("%d",&n)!=EOF)
{
for(i=;i<n;i++)
{
scanf("%d",&nums[i]);
}
sort(nums,nums+n);
if(n%==)
printf("%.1f\n",double(nums[(n-)/]));
if(n%==)
printf("%.1f\n",nums[n/-]/2.0+nums[n/]/2.0);
}
return ;
}
今天被这个题目坑了。
(poj)Sequence Median的更多相关文章
- Coursera Deep Learning笔记 序列模型(三)Sequence models & Attention mechanism(序列模型和注意力机制)
参考 1. 基础模型(Basic Model) Sequence to sequence模型(Seq2Seq) 从机器翻译到语音识别方面都有着广泛的应用. 举例: 该机器翻译问题,可以使用" ...
- poj 2623 Sequence Median 堆的灵活运用
I - Sequence Median Time Limit:1000MS Memory Limit:1024KB 64bit IO Format:%I64d & %I64u ...
- (poj)3159 Candies
题目链接:http://poj.org/problem?id=3159 Description During the kindergarten days, flymouse was the monit ...
- (poj)1502 MPI Maelstrom
题目链接:http://poj.org/problem?id=1502 Description BIT has recently taken delivery of their processor A ...
- (poj)1806 Currency Exchange
题目链接:http://poj.org/problem?id=1860 Description Several currency exchange points are working in our ...
- (poj)3268 Silver Cow Party 最短路
Description One cow ≤ N ≤ ) conveniently numbered ..N ≤ X ≤ N). A total of M ( ≤ M ≤ ,) unidirection ...
- (poj)3020 Antenna Placement 匹配
题目链接 : http://poj.org/problem?id=3020 Description The Global Aerial Research Centre has been allotte ...
- (poj)1064 Cable master 二分+精度
题目链接:http://poj.org/problem?id=1064 Description Inhabitants of the Wonderland have decided to hold a ...
- (poj)3414 Pots (输出路径的广搜)
Description You are given two pots, having the volume of A and B liters respectively. The following ...
随机推荐
- Q&A - 如何获取ip地址所在地
获取其IP地址后,传入以下URL,并请求该URL,该请求会响应一个JSON格式的数据包,该IP地址的所在地均在这个数据包内 http://int.dpool.sina.com.cn/iplooku ...
- django+xadmin在线教育平台(九)
django admin介绍 上一章我们进行了需求分析和数据库设计.本章我们来快速搭建一个可用的后台管理系统. 后台管理系统特点: 权限管理 少前端样式.(样式一般不是很看重), 快速开发 djang ...
- go get超时解决办法
go get gopkg.in/yaml.v2超时,发现被墙了,解决办法如下: 1.安装golang.org/x/net $ mkdir -p $GOPATH/src/golang.org/x/ $ ...
- tcl之array操作
- composer安装教程(Linux版)
composer 是款不错的工具,那么如何进行安装composer呢 如果您是linux系统或是mac系统 请先确定是否安装了curl linux安装curl 1 yum install -y c ...
- python——PIL(图像处理库)
PIL(Python Imaging Library,python图像处理库)提供了通用的图像处理功能,以及大量有用的基本图像操作,如图像缩放,裁剪,旋转,颜色转换等. 1.打开图像并显示 from ...
- 字典--数据结构与算法JavaScript描述(7)
字典 字典是一种以键-值对形式存储数据的数据结构. Dictionary 类 Dictionary 类的基础是Array 类,而不是Object 类. function Dictionary( ){ ...
- Redis和Mecahe的简介
Memcache介绍 概念:Memcache是一个高性能,分布式内存对象缓存系统,通过在内存里维护一个统一的巨大的hash表,它能够用来存储各种格式的数据,包括图像.视频.文件以及数据库检索的结果等. ...
- 用 Flask 来写个轻博客
用 Flask 来写个轻博客 用 Flask 来写个轻博客 (1) — 创建项目 用 Flask 来写个轻博客 (2) — Hello World! 用 Flask 来写个轻博客 (3) — (M)V ...
- 《Cracking the Coding Interview》——第3章:栈和队列——题目4
2014-03-18 05:28 题目:你肯定听过汉诺威塔的故事:三个柱子和N个从小到大的盘子.既然每次你只能移动放在顶上的盘子,这不就是栈操作吗?所以,请用三个栈来模拟N级汉诺威塔的玩法.放心,N不 ...