题目链接:http://poj.org/problem?id=2231

思路分析:先排序,再推导计算公式。

代码如下:

#include <iostream>
#include <algorithm>
using namespace std; int main()
{
long long int ans = , arr[];
int n, m; cin >> n;
for ( int i = ; i < n; ++i )
{
cin >> arr[i];
} sort( arr, arr + n ); for ( int i = ; i < n; ++i )
{
ans += ( n--i ) * ( arr[n--i] - arr[i] );
}
cout << ans * <<endl; return ;
}

Poj 2232 Moo Volume(排序)的更多相关文章

  1. POJ 2231 Moo Volume

    Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Description Farmer Jo ...

  2. BZOJ1679: [Usaco2005 Jan]Moo Volume 牛的呼声

    1679: [Usaco2005 Jan]Moo Volume 牛的呼声 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 723  Solved: 346[ ...

  3. POJ 2010 Moo University - Financial Aid( 优先队列+二分查找)

    POJ 2010 Moo University - Financial Aid 题目大意,从C头申请读书的牛中选出N头,这N头牛的需要的额外学费之和不能超过F,并且要使得这N头牛的中位数最大.若不存在 ...

  4. BZOJ 1679: [Usaco2005 Jan]Moo Volume 牛的呼声( )

    一开始直接 O( n² ) 暴力..结果就 A 了... USACO 数据是有多弱 = = 先sort , 然后自己再YY一下就能想出来...具体看code --------------------- ...

  5. Poj2231 Moo Volume 2017-03-11 22:58 30人阅读 评论(0) 收藏

    Moo Volume Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22104   Accepted: 6692 Descr ...

  6. Moo Volume POJ - 2231

    Farmer John has received a noise complaint from his neighbor, Farmer Bob, stating that his cows are ...

  7. poj -2010 Moo University - Financial Aid (优先队列)

    http://poj.org/problem?id=2010 "Moo U"大学有一种非常严格的入学考试(CSAT) ,每头小牛都会有一个得分.然而,"Moo U&quo ...

  8. B - Moo Volume

    Farmer John has received a noise complaint from his neighbor, Farmer Bob, stating that his cows are ...

  9. 【BZOJ】1679: [Usaco2005 Jan]Moo Volume 牛的呼声(数学)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1679 水题没啥好说的..自己用笔画画就懂了 将点排序,然后每一次的点到后边点的声音距离和==(n-i ...

随机推荐

  1. VC++ SetLayeredWindowAttributes 部分窗口透明鼠标穿透

    在初始化中使用下面两行代码 ModifyStyleEx(0, WS_EX_LAYERED); ::SetLayeredWindowAttributes(m_hWnd, RGB(1, 255, 0), ...

  2. SGU 101.Domino( 欧拉路径 )

    求欧拉路径...直接dfs即可,时间复杂度O(N) -------------------------------------------------------------------------- ...

  3. jquery validationEngine 使用ajax验证不通过也提交表单

    转自 http://mylfd.iteye.com/blog/2007227 validationEngine给我们为前端的表单验证减少了很大的工作量.大部分情况我们使用validationEngin ...

  4. H3C交换配置PBR最佳实践

    简要说明 PBR算是比较常用的功能,需要我们去掌握一下 配置步骤简要 配置BFD 配置track 配置acl 配置policy-based-route 在接口上面应用policy-based-rout ...

  5. Linux 硬盘、网卡

    根据硬盘接口的不同,在Liunx中会有不同的命名 IDE 接口的硬盘会被叫成: hda,hdb,hdc (hd -- hard disk) hda 表示第一块硬盘,hdb表示第二块硬盘! 一般来说我们 ...

  6. nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException

    You should autowire interface AbstractManager instead of class MailManager. If you have different im ...

  7. openStack juno for ubuntu12-04

    <一,preinstall basic conf,pre Env> 1,pwgen(openssl rand -hex 10) some Open-Stack services add a ...

  8. openStack开源云repo db local or on-line 实战部署之Ruiy王者归来

    preface/pre,获取OpenStack核心模块组件及其子组件包(当前仅针对centos6*)及其依赖包 eg,picture

  9. 动画画圆的效果特效ios源码

    一款不错的支持动画画圆的效果特效源码,该效果实现了动画画圆,还可以扩展成画其他平面图形功能等,大家可以下载看看吧. //定义所需要画的图形  -(void)intiUIOfView  {      U ...

  10. 移动mmbilling似乎有个BUG,通过JNI调用会抛出异常

    有人用JNI调用过mm么?不知道你成功了没有,我试了多种方法,有一个错误始终存在,怀疑上个BUG.使用方式: 通过NativeActivity的clazz获取ClassLoader,然后找到mm.pu ...