UVa Problem 10041 Vito’s Family (Vito 家族)
// Vito’s Family (Vito 家族)
// PC/UVa IDs: 110401/10041, Popularity: A, Success rate: high Level: 1
// Verdict: Accepted
// Submission Date: 2011-05-21
// UVa Run Time: 0.104s
//
// 版权所有(C)2011,邱秋。metaphysis # yeah dot net
//
// 一组数据,如果要求一个数,该数与所有数据的差的绝对值和最小,则该数是这组数据的中位数。 #include <iostream>
#include <algorithm>using namespace std;#define MAXSIZE 500int main(int ac, char *av[])
{int cases, total;int address[MAXSIZE];cin >> cases;while (cases--){cin >> total;int counter = 0;while (counter < total)cin >> address[counter++];sort(address, address + total);// 找到中位数并求和,注意该题所求的中位数须为整数。int middle;if (total & 1)middle = address[total / 2];elsemiddle = (int) (((float) (address[total / 2 - 1] +address[total / 2]) * 5.0 + 5.0) / 10.0);long shortest = 0;for (int i = 0; i < total; i++){int distance = middle - address[i];shortest += (distance >= 0 ? distance : (-1) * distance);}cout << shortest << endl;}return 0;
}
UVa Problem 10041 Vito’s Family (Vito 家族)相关推荐
- UVa Problem 123 - Searching Quickly
// UVa Problem 123 - Searching Quickly // Verdict: Accepted // Submission Date: 2012-01-04 // UVa Ru ...
- UVa Problem 109 - SCUD Busters
// UVa Problem 109 - SCUD Busters // Verdict: Accepted // Submission Date: 2011-11-24 // UVa Run Tim ...
- UVa Problem 10310 Dog and Gopher (狗拿地鼠)
// Dog and Gopher (狗拿地鼠) // PC/UVa IDs: 111301/10310, Popularity: A, Success rate: average Level: 1 ...
- UVa Problem 10001 Garden of Eden (伊甸园)
// Garden of Eden (伊甸园) // PC/UVa IDs: 110806/10001, Popularity: B, Success rate: average Level: 2 / ...
- UVa Problem 10254 The Priest Mathematician (牧师数学家)
// The Priest Mathematician (牧师数学家) // PC/UVa IDs: 110606/10254, Popularity: C, Success rate: high L ...
- UVa Problem 10067 Playing With Wheels (摆弄轮子)
// Playing With Wheels (摆弄轮子) // PC/UVa IDs: 110902/10067, Popularity: C, Success rate: average Leve ...
- UVa Problem 10205 Stack ’em Up (完美洗牌术)
// Stack 'em Up (完美洗牌术) // PC/UVa IDs: 110205/10205, Popularity: B, Success rate: average Level: 1 / ...
- 哈佛大学统计学教材_哈佛校友在职场上的统计数据
哈佛大学统计学教材 By: Asher Noel and Alicia Wu 作者:Asher Noel和Alicia Wu On May 6, the Group for Undergraduate ...
- 整理:ACM相关好的网站 OJ Blog (不断更新)
ACM-ICPC世界网站 http://acm.timus.ru http://acm.sgu.ru http://acm.hnu.cn http://acm.hdu.edu.cn http://ac ...
最新文章
- 深圳某女孩身家上千万,却称自己不配追求大厂程序员
- 华为p20可以用云闪付吗_华为hcIE有多难?零基础可以通过华为hcie认证吗?
- java if else嵌套,减少的 if else 嵌套 可以使用java 8的Consumer
- TensorFlow:实战Google深度学习框架(四)MNIST数据集识别问题
- JavaScript-jQuery操作Dom元素
- Maven——windows下安装配置及IDEA设置本地仓库的步骤总结
- 动态路由协议之OSPF
- select * from什么意思_SQL入门教程第15课:什么是内连接
- xshell 登录kail拒绝了密码 已解决
- 服务器开机信号,机柜服务器BMC开关机控制系统及方法
- bzoj 1046: [HAOI2007]上升序列【dp+二分】
- 比特币以太坊数字货币钱包安全助记词安全问题
- ios-后台运行UIApplication
- layui 之 laypage分页插件
- 五子棋(人人对战、人机对战均可)
- 微信小程序如何快速达到1000UV流量主开通要求
- 以太坊生态缺陷导致的一起亿级代币盗窃大案
- linux内核驱动使用hugepages,Linux系统下快速配置HugePages的完整步骤
- 如何执行IntelliJ IDEA 中的.sql文件
- 我打算去广东第一“鬼城”,买房安家