(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 ...
随机推荐
- jQuery-laye插件实现 弹框编辑,异步验证,form验证提交
代码中用到了 jQuery的ajax异步处理,each()循环,submit()页面验证提交form表单,prepend()追加标签,laye插件的弹框效果(如有其它弹框效果可参考官网:http:// ...
- 浏览器进程/线程模型及JS运行机制
浏览器是多进程的,有一个主控进程,以及每一个tab页面都会新开一个进程(某些情况下多个tab会合并进程). 进程可能包括主控进程,插件进程,GPU,tab页(浏览器内核)等等. Browser进程:浏 ...
- manjaro无法使用ifconfig查ip
manjaro中自带的查看网络的命令是: ip addr 可以了解一下ip命令都有哪些功能 如果还是想要 ifconfig 需要安装net-tools 安装命令: sudo pacman -S net ...
- Error: Cannot find module 'core-js/fn/array/values' at Function.Module._resolveFilename (module
E:\codeBase\top605\rescue-master\server\node_modules\_log4js@1.1.1@log4js\lib\log4js.js:321 throw ne ...
- BFS例题:A计划
ContribContrib/a11y/accessibility-menu.js 关于 BFS要点: 1.若为可化为的坐标系图形,可用结构体存储其x值,y值和步数.(一般开now 和 next ,n ...
- 笔记-python-functool-@wraps
笔记-python-functool-@wraps 1. wraps 经常看到@wraps装饰器,查阅文档学习一下 在了解它之前,先了解一下partial和updata_wrapper这两个 ...
- <s:submit> 指定的method方法不执行
很多文章在讲一个表单多个提交方法的时候都是在<s:submit>中通过method来指定,但是我在试验中怎么也不对,jsp页面代码如下 <%@page import="or ...
- CSS计数器(自定义列表)Demo
html <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <ti ...
- USACO Section2.2 Runaround Numbers 解题报告 【icedream61】
runround解题报告---------------------------------------------------------------------------------------- ...
- [译]17-spring基于java代码的配置元数据
spring还支持基于java代码的配置元数据.不过这种方式不太常用,但是还有一些人使用.所以还是很有必要介绍一下. spring基于java代码的配置元数据,可以通过@Configuration注解 ...