Poj 2232 Moo Volume(排序)
题目链接: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(排序)的更多相关文章
- POJ 2231 Moo Volume
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Description Farmer Jo ...
- BZOJ1679: [Usaco2005 Jan]Moo Volume 牛的呼声
1679: [Usaco2005 Jan]Moo Volume 牛的呼声 Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 723 Solved: 346[ ...
- POJ 2010 Moo University - Financial Aid( 优先队列+二分查找)
POJ 2010 Moo University - Financial Aid 题目大意,从C头申请读书的牛中选出N头,这N头牛的需要的额外学费之和不能超过F,并且要使得这N头牛的中位数最大.若不存在 ...
- BZOJ 1679: [Usaco2005 Jan]Moo Volume 牛的呼声( )
一开始直接 O( n² ) 暴力..结果就 A 了... USACO 数据是有多弱 = = 先sort , 然后自己再YY一下就能想出来...具体看code --------------------- ...
- Poj2231 Moo Volume 2017-03-11 22:58 30人阅读 评论(0) 收藏
Moo Volume Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22104 Accepted: 6692 Descr ...
- Moo Volume POJ - 2231
Farmer John has received a noise complaint from his neighbor, Farmer Bob, stating that his cows are ...
- poj -2010 Moo University - Financial Aid (优先队列)
http://poj.org/problem?id=2010 "Moo U"大学有一种非常严格的入学考试(CSAT) ,每头小牛都会有一个得分.然而,"Moo U&quo ...
- B - Moo Volume
Farmer John has received a noise complaint from his neighbor, Farmer Bob, stating that his cows are ...
- 【BZOJ】1679: [Usaco2005 Jan]Moo Volume 牛的呼声(数学)
http://www.lydsy.com/JudgeOnline/problem.php?id=1679 水题没啥好说的..自己用笔画画就懂了 将点排序,然后每一次的点到后边点的声音距离和==(n-i ...
随机推荐
- CLLocation
http://blog.sina.com.cn/s/blog_9e8867eb01013knc.html 这家伙写的不错本人也参考了这篇博客,希望原文博主可以谅解新手的无奈举措 首相要提到的类是 CL ...
- unexpected token: null near line 1, column 290
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: null near line 1, column 290 ...
- [非技术参考]C# Socket网络编程
我们在讲解Socket编程前,先看几个和Socket编程紧密相关的概念: 1. TCP/IP层次模型 当然这里我们只讨论重要的四层 01,应用层(Application):应用层是个很广泛的概念,有一 ...
- Kafka主要参数详解
原文档地址:http://kafka.apache.org/documentation.html https://kafka.apache.org/08/documentation#configur ...
- PHP无法获取Referer问题排查
测试结果: 同一个页面,2次打开,第一次能获取到Referer第二次获取不到,很好奇原因所在. test1.php代码是: <?php echo '测试来源:直接载入页面<br/>' ...
- poj 1949 Chores 最长路
题目链接 求出最长路..... #include <iostream> #include <vector> #include <cstdio> #include & ...
- ios 加水印
1.加文字 -(UIImage *)addText:(UIImage *)img text:(NSString *)text1 { //get image width and ...
- mysql 性别存储
大家在设计数据库时,碰到 性别.状态等 这些 值比较固定的列时,数据类型 是如何定义? 通常都是采用 : 1 create table `XXX` 2 ( 3 ........ 4 sex int(1 ...
- Dialog with HTML skin using CDHtmlDialog and SetWindowRgn
Introduction This program demonstrates how to use CDHtmlDialog and SetWindowRgn functions to give a ...
- HDU 5823 color II(FWT)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5823 [题目大意] 定义一张无向图的价值:给每个节点染色使得每条边连接的两个节点颜色不相同的最少颜 ...