2014
02-24

# Fairies’ Defence

There are n fairies living happily in the Fairyland. One day, when the fairies are playing games, they are suddenly stuck in the sky and cannot move anymore! "Your moving abilities are sealed by my magic. Be ready to defense my attack!" a terrible voice came out, "I’ll appear in the cube (0, 0, 0)-(a, b, c), rush to the nearest fairy and then, make my assault with all my power!"
Since all the fairies cannot move any more, the only chance is to redistribute their defense powers according to their dangerousness. Formally, the defense power one fairy gains should be proportional to its probability to be attacked by the unknown fierce creature.
Write a program to compute the probability to be attacked, for every fairy. You may assume that the probability density of the attacker’s initial position is the same everywhere in the cube; if there are at least two fairies closest (having the minimal Euclidean distance) to the initial position, any one may be attacked.

The input consists of several test cases. The first line of each case contains four integers, n, a, b, c (2 ≤ n ≤ 20, 1 ≤ a, b, c ≤ 1000). This is followed by n lines, each containing three integers x, y, z (0 ≤ x ≤ a, 0 ≤ y ≤ b, 0 ≤ z ≤ c), the coordinates of the fairies. No two fairies occupy the same position. The last test case is followed by a single zero, which should not be processed.

The input consists of several test cases. The first line of each case contains four integers, n, a, b, c (2 ≤ n ≤ 20, 1 ≤ a, b, c ≤ 1000). This is followed by n lines, each containing three integers x, y, z (0 ≤ x ≤ a, 0 ≤ y ≤ b, 0 ≤ z ≤ c), the coordinates of the fairies. No two fairies occupy the same position. The last test case is followed by a single zero, which should not be processed.

2 3 3 3
1 1 1
2 2 2
2 7 2 10
1 1 6
3 1 6
0

Case 1: 0.500 0.500
Case 2: 0.286 0.714

HDU_2933

具体的思路可以参考《浅谈数形结合思想在信息学竞赛中的应用》

#include<stdio.h>
#include<string.h>
#include<algorithm>
#define MAXD 100010
typedef long long LL;
int N, K, A[MAXD], q[MAXD];
void cin(int &x)
{
char ch;
while(ch = getchar(), ch < '0' || ch > '9');
x = ch - '0';
while(ch = getchar(), ch >= '0' && ch <= '9')
x = (x << 3) + (x << 1) + ch - '0';
}
void init()
{
int i;
A[0] = 0;
for(i = 1; i <= N; i ++) cin(A[i]), A[i] += A[i - 1];
}
void solve()
{
int i, j, x, y, z, front, rear;
double ans = 0;
front = rear = 0;
q[rear ++] = 0;
for(i = K; i <= N; i ++)
{
while(front < rear - 1)
{
x = q[front], y = q[front + 1];
if((LL)(A[i] - A[x]) * (i - y) > (LL)(A[i] - A[y]) * (i - x)) break;
++ front;
}
ans = std::max(ans, (double)(A[i] - A[q[front]]) / (i - q[front]));
q[rear] = i - K + 1;
while(front < rear - 1)
{
x = q[rear - 2], y = q[rear - 1], z = q[rear];
if((LL)(A[z] - A[y]) * (y - x) > (LL)(A[y] - A[x]) * (z - y)) break;
-- rear, q[rear] = q[rear + 1];
}
++ rear;
}
printf("%.2f\n", ans);
}
int main()
{
while(scanf("%d%d", &N, &K) == 2)
{
init();
solve();
}
return 0;
}

1. Hello Web Admin, I noticed that your On-Page SEO is is missing a few factors, for one you do not use all three H tags in your post, also I notice that you are not using bold or italics properly in your SEO optimization. On-Page SEO means more now than ever since the new Google update: Panda. No longer are backlinks and simply pinging or sending out a RSS feed the key to getting Google PageRank or Alexa Rankings, You now NEED On-Page SEO. So what is good On-Page SEO?First your keyword must appear in the title.Then it must appear in the URL.You have to optimize your keyword and make sure that it has a nice keyword density of 3-5% in your article with relevant LSI (Latent Semantic Indexing). Then you should spread all H1,H2,H3 tags in your article.Your Keyword should appear in your first paragraph and in the last sentence of the page. You should have relevant usage of Bold and italics of your keyword.There should be one internal link to a page on your blog and you should have one image with an alt tag that has your keyword….wait there's even more Now what if i told you there was a simple WordPress plugin that does all the On-Page SEO, and automatically for you? That's right AUTOMATICALLY, just watch this 4minute video for more information at.

2. 学算法中的数据结构学到一定程度会乐此不疲的，比如其中的2－3树，类似的红黑树，我甚至可以自己写个逻辑文件系统结构来。

3. 问题3是不是应该为1/4 .因为截取的三段，无论是否能组成三角形， x， y-x ，1-y,都应大于0，所以 x<y,基础应该是一个大三角形。小三角是大三角的 1/4.