poj2926 2010.2.26
来源:互联网 发布:浙江网络诈骗立案标准 编辑:程序博客网 时间:2024/05/22 03:39
poj2926 2010.2.26
Requirements
Time Limit: 5000MS Memory Limit: 65536K
Total Submissions: 2926 Accepted: 846
Description
An undergraduate student, realizing that heneeds to do research to improve his chances of being accepted to graduateschool, decided that it is now time to do some independent research. Of course,he has decided to do research in the most important domain: the requirements hemust fulfill to graduate from his undergraduate university. First, hediscovered (to his surprise) that he has to fulfill 5 distinct requirements:the general institute requirement, the writing requirement, the sciencerequirement, the foreign-language requirement, and the field-of-specializationrequirement. Formally, a requirement is a fixed number of classes that he hasto take during his undergraduate years. Thus, for example, the foreign languagerequirement specifies that the student has to take 4 classes to fulfill thisrequirement: French I, French II, French III, and French IV. Having analyzedthe immense multitude of the classes that need to be taken to fulfill thedifferent requirements, our student became a little depressed about hisundergraduate university: there are so many classes to take…
Dejected, the student began studying therequirements of other universities that he might have chosen after high school.He found that, in fact, other universities had exactly the same 5 requirementsas his own university. The only difference was that different universities haddifferent number of classes to be satisfied in each of the five requirement.
Still, it appeared that universities havepretty similar requirements (all of them require a lot of classes), so hehypothesized that no two universities are very dissimilar in theirrequirements. He defined the dissimilarity of two universities X and Y as |x1 −y1| + |x2 − y2| + |x3 − y3| + |x4 − y4| + |x5 − y5|, where an xi (yi) is thenumber of classes in the requirement i of university X (Y) multiplied by anappropriate factor that measures hardness of the corresponding requirement atthe corresponding university.
Input
The first line of the input file containsan integer N (1 ≤ N ≤ 100 000), the number of considered universities. The following Nlines each describe the requirements of a university. A university X isdescribed by the five non-negative real numbers x1 x2 x3 x4 x5.
Output
On a single line, print the dissimilarityvalue of the two most dissimilar universities. Your answer should be rounded toexactly two decimal places.
Sample Input
3
2 5 6 2 1.5
1.2 3 2 5 4
7 5 3 2 5
Sample Output
12.80
Source
MIT Programming Contest 2005
#include <cstdio>#include <cstring>#define N 100000+10double data[N][5],list[N];int n;int main(){scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%lf %lf %lf %lf %lf",data[i],data[i]+1,data[i]+2,data[i]+3,data[i]+4);double maxsub=0;for(int k=0;k<32;k++){double max=-1e250,min=1e250;for(int i=1;i<=n;i++){double sum=((k&1)?data[i][0]:-data[i][0])+((k&2)?data[i][1]:-data[i][1])+((k&4)?data[i][2]:-data[i][2])+((k&8)?data[i][3]:-data[i][3])+((k&16)?data[i][4]:-data[i][4]);//用按位与看哪位上是1,0max=sum>max?sum:max;min=sum<min?sum:min;}maxsub=(max-min)>maxsub?(max-min):maxsub;}printf("%.2lf\n",maxsub);return 0;}
- poj2926 2010.2.26
- poj2926 Requirements
- HDU4666+POJ2926【最远曼哈顿距离】
- 【最大曼哈顿距离】POJ2926 Requirements
- 【POJ2926】Requirements【二进制】【最大曼哈顿距离】
- POJ2926-Requirements,曼哈顿距离。去掉绝对值符号暴力枚举所有情况,神薙!
- 2010.2.26
- hdu2824 2010.2.26
- 2010.2.10
- 2010.2.22
- 2010.2.23
- 2010.2.24
- 2010.2.25
- 2010.2.23
- 2010.2.1 星期一 晴
- 2010.2.2日記
- 2010.2.5晴
- 2010.2月总结
- hdu2817 2010.2.25
- [Unity3D]Window Phone代码通信
- poj1001 2010.2.25
- hdu2824 2010.2.26
- L2 正则化
- poj2926 2010.2.26
- Java设计模式(十八)----命令模式
- hdu3220 2010.3.1
- HDU 3639 Hawk-and-Chicken(强连通分量+缩点)
- XStream的使用(2)——集合形式的 JavaBean 转化为 xml
- HYSBZ/BZOJ 1037 [ZJOI2008] 生日聚会Party - dp
- Etaoin Shrdlu 2010.3.2
- frm.Show();Application.Run
- Android开发笔记(五十七)录像录音与播放