日期:2014-05-20  浏览次数:20580 次

一个题目没思路。。。求各位指点下
Problem Description and Background
The planet Pern, in a faraway star system, has been settled by humans. Every 200 years or so, Pern is plagued by Thread. Thread comes from outer space and falls through the atmosphere. If Thread reaches the ground then it destroys plants and animals (including humans). The people of Pern have fire breathing dragons, ridden by humans. When Thread falls the dragons and riders rise up into the air and attempt to destroy the Thread before it reaches the ground. If a dragon is close enough to a patch of Thread then its flame completely destroys the Thread.

Dragons come in different sizes, this is based on the colour of the dragon. Bigger dragons have a bigger wingspan which means that they can go up and down faster than smaller dragons. However bigger dragons don't go left or right as well as smaller dragons.

Bigger dragons also have a stronger flame which means they can be further away from Thread when they attempt to destroy it, than smaller dragons, and still succeed.

This is known as the flame distance.

When Thread starts to fall the Dragons (and riders) know that Thread has started to fall, but they don't know exactly where. So the dragon starts at a certain location in the sky. When the dragon and rider see the position of the Thread then they have to try and fly to the position of the Thread.

The position of Thread is recorded using two co-ordinates, x1 and y1, for example. The x1 (horizontal) coordinate is the distance (plus or minus) from some arbitrary point on the ground. The y1 (vertical) coordinate is the height above the ground.

The position of the dragon is also recorded using two coordinates, x2 and y2, for example. The x2 (horizontal) coordinate is the distance (plus or minus) from the same arbitrary point on the ground as is used for Thread. The y2 (vertical) coordinate is the height of the dragon above the ground.
 
In the action against Thread the flight is divided up into time slices. In one time slice, Thread falls 100 units or is blown horizontally 100 units left or right. When a dragon carries out a menu choice, this also lasts for the whole time slice.

± means plus or minus

All dragons go left or right using this formula newX = oldX ± ((100 / wingspan) * 50 )
to go left makes newX less than oldX so subtract to go right makes newX greater than oldX so add

NOTE: x can be negative

All dragons go up or down using this formula newY = oldY ± (wingspan * 5 )
Dragons never crash into the ground, they land, so if newY is negative make it zero
The formula for working out the distance between 2 points is distance = √ (x2 - x1)2 + (y2 - y1)2

Thread can go down, left or right.

This is determined randomly which is explained below.

Working out the next position of Thread.

Generate a random number between 0 and 16 (exclusive)

If the random number is 0, 3 or 11
then the new x1 (horizontal) position of Thread is 100 units to the right. the y1 (vertical) position stays the same.

If the random number is 5, 9 or 14
then the new x1 (horizontal) position of Thread is 100 units to the left. the y1 (vertical) position stays the same.