Hdoj HDU 2059 Tortoise and rabbit race ACM 2059 In HDU

Source: Internet
Author: User
Miyu original, post Please note: Reprinted from __________ White House

Question address:
Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 2059
Description:
Problem description
It is said that a long time ago, the poor rabbit experienced the biggest blow in his life-after losing the race to the tortoise, his heart was depressed and vowed to report revenge and hate, so he hid in a Agricultural Park in Xiasha, Hangzhou, and tried his best practice, finally, it became a stunt to be able to maintain a constant speed without any rest (VR m / S) Keep running. The rabbit has been trying to find a chance to teach the tortoise a lesson.
Recently, the 50 Anniversary of HDU was celebrated. Celebrities gathered in the sand and rabbits took the opportunity to challenge turtles. Although the tortoise knows that there is little hope for victory, he can only accept the challenge due to public opinion pressure.
The game is located on a straight road with a length of L meters. The rule is very simple. Whoever reaches the end will win.
But since the victory, the tortoise has become a tortoise, and some gossip magazines call it "Liu Xiang of the animal community". The advertisement keeps on, and there is a lot of savings on hand. In order to win the rabbit again, the tortoise bought the most advanced weapon-" " Little Flying Pigeon " Brand electric vehicles. The car can run on vt1 m / S's speed is "Flying", but the battery capacity is limited. Every time the power is fully charged, you can only drive a distance of C meters. In the future, you can only use your feet to pedal, when the tortoise uses the pedal, the speed is VT2 M. / S. Even more, turtles have built many (n) power supply stations on the runway to charge their own electric vehicles. It takes t seconds for each charge. Of course, when the tortoise passes through a charging station, they can choose to or not charge.
the competition is about to begin. rabbits and electric-powered turtles are standing at the starting line. Your task is to write a Program to determine whether the tortoise can win a rabbit that has been running at a constant speed when using the best solution.

input
this topic contains multiple groups of tests. Please process it until the end of the file. Each test contains four rows:
the first row is an integer l representing the total length of the runway
the second row contains three integers N, C, T, represents the number of charging stations, the distance that an electric car can travel after it is fully powered, and the time required for each charging
the third line is also three integers: vr, vt1, VT2, the speed of the rabbit running, the speed of the tortoise driving the electric car, and the speed of the electric car with the tortoise pedal
the fourth line contains n (n <= 100 ) the integer P1 and p2pn respectively indicate the distance between each charging station and the start point of the runway, where 0 P1 P2 PN L
Each number is within the 32-bit integer range.

Output
When the tortoise may win, output a line "what a pity Rabbit ".!". Otherwise, output a row."Good job, rabbit!";
The problem data ensures that the turtles and rabbits arrive at the same time.
 

Sample Input
100
3   20   5
5   8   2
10   40   60
100
3   60   5
5   8   2
10   40   60
 

Sample output
Good job, rabbit!
What a pity rabbit!

Question Analysis:
We can check n + 2 points (this is the key) for the start point and end point and N charging stations)
The BST [n + 2] array is defined to save the shortest time for a turtle to arrive at each station.
BST [0] = 0.
When site I is reached, making J cycle from 0-> I-1 indicates that the power from station J is fully loaded to station I.
The shortest time for arriving at station I.
Here we have the state transition equation:
I am wrong. I don't know how to express it. Who knows the trouble? Thank you.
Code As follows: // Original miyu, please note: Reprinted from __________ White House
# Include < Iostream >
Int Dis [ 102 ];
Double BST [ 102 ];
Int Main ()
{
Int L;
While (Scanf ( " % D " , & L) ! = EOF)
{
Int VR, V1, V2, N, C, T;
Scanf ( " % D " , & N, & C, & T );
Scanf ( " % D " , & VR, & V1, & V2 );
BST [ 0 ] = Dis [ 0 ] =   0 ;
For ( Int I =   1 ; I <= N; ++ I)
{
Scanf ( " % D " , & Dis [I]);
}
Dis [n +   1 ] = L;
For ( Int I =   1 ; I ! = N + 2 ; ++ I)
{
Double Min =   0 xfffff ;
For ( Int J =   0 ; J ! = I; ++ J)
{
Int Len = Dis [I] - Dis [J];
Double Temp = Len > C ?   1.0   * C / V1 + (Len - C) *   1.0   / V2: 1.0   * Len / V1; // Time when the turtle was fully powered from the J charging station to the I charging station
Temp + = BST [J];
If (J) // Don't forget to charge at the starting point, or it's really depressing.
{
Temp + = T;
}
If (Min > Temp) // Obtain the minimum value of the time used to arrive at the I site.
{
Min = Temp;
}
}
BST [I] = Min; // Save the minimum value that reaches station I
}
Puts ( 1.0   * L / Vr > BST [n +   1 ] ?   " What a pity rabbit! " : " Good job, Rabbit! " );
}

Return   0 ;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.