2015
05-23

# Party All the Time

In the Dark forest, there is a Fairy kingdom where all the spirits will go together and Celebrate the harvest every year. But there is one thing you may not know that they hate walking so much that they would prefer to stay at home if they need to walk a long way.According to our observation,a spirit weighing W will increase its unhappyness for S3*W units if it walks a distance of S kilometers.
Now give you every spirit’s weight and location,find the best place to celebrate the harvest which make the sum of unhappyness of every spirit the least.

The first line of the input is the number T(T<=20), which is the number of cases followed. The first line of each case consists of one integer N(1<=N<=50000), indicating the number of spirits. Then comes N lines in the order that x[i]<=x[i+1] for all i(1<=i<N). The i-th line contains two real number : Xi,Wi, representing the location and the weight of the i-th spirit. ( |xi|<=106, 0<wi<15 )

The first line of the input is the number T(T<=20), which is the number of cases followed. The first line of each case consists of one integer N(1<=N<=50000), indicating the number of spirits. Then comes N lines in the order that x[i]<=x[i+1] for all i(1<=i<N). The i-th line contains two real number : Xi,Wi, representing the location and the weight of the i-th spirit. ( |xi|<=106, 0<wi<15 )

1
4
0.6 5
3.9 10
5.1 7
8.4 10

Case #1: 832

(/ □ \)。。。。之前标题一不小心写成整了好久的4351了……被标题“骗进来”的童鞋不好意思。。

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
const int N = 10e4+1;
const float eps = 1e-2;
struct po
{
double x;
double w;
} point[N];
int main()
{
//    freopen("1006.txt","r",stdin);
int t;
scanf("%d",&t);
for(int cases = 1; cases<=t; cases++)
{
int n;
scanf("%d",&n);
for(int i=1; i<=n; i++)
scanf("%lf %lf",&point[i].x,&point[i].w);
double low = point[1].x;
double high = point[n].x;
double sum1 = 10;
double sum2 = 0;
while(fabs(sum1-sum2)>eps)
{
double mid1 = low + (high-low)/3;
double mid2 = high - (high-low)/3;
sum1 = sum2 = 0;
for(int i=1; i<=n; i++)
{
sum1 += pow((fabs(point[i].x - mid1)),3)*point[i].w;
sum2 += pow((fabs(point[i].x - mid2)),3)*point[i].w;
}
if(sum1<sum2)
high = mid2;
else if(sum1>sum2)
low = mid1;
else if(sum1==sum2)
low = high;
}
printf("Case #%d: %.0lf\n",cases,sum1);
}
return 0;
}


,
1. 纯种美国血统……这同学叫我感觉很纠结，美国本来就是外来移民的国家，如果非要说本土纯粹的话，我理解应该是印第安人血统了。

2. 纯种美国血统……这同学叫我感觉很纠结，美国本来就是外来移民的国家，如果非要说本土纯粹的话，我理解应该是印第安人血统了。

3. 纯种美国血统……这同学叫我感觉很纠结，美国本来就是外来移民的国家，如果非要说本土纯粹的话，我理解应该是印第安人血统了。

4. 纯种美国血统……这同学叫我感觉很纠结，美国本来就是外来移民的国家，如果非要说本土纯粹的话，我理解应该是印第安人血统了。

5. 纯种美国血统……这同学叫我感觉很纠结，美国本来就是外来移民的国家，如果非要说本土纯粹的话，我理解应该是印第安人血统了。

6. 纯种美国血统……这同学叫我感觉很纠结，美国本来就是外来移民的国家，如果非要说本土纯粹的话，我理解应该是印第安人血统了。

7. 纯种美国血统……这同学叫我感觉很纠结，美国本来就是外来移民的国家，如果非要说本土纯粹的话，我理解应该是印第安人血统了。

8. 纯种美国血统……这同学叫我感觉很纠结，美国本来就是外来移民的国家，如果非要说本土纯粹的话，我理解应该是印第安人血统了。