Hdu2059_ Turtle and Rabbit race

Source: Internet
Author: User

Turtle and Rabbit race

Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)Total Submission (s): 11753 Accepted Submission (s): 4419
Problem Description
It is said that in a long long time ago, poor rabbit experienced the biggest blow in life-the race lost to the turtle, heart depressed, vowed to avenge, so hid in the Hangzhou Xiasha Agricultural Park hardships painstaking practice, and finally practiced into a stunt, can not rest at a constant speed (VR m/s) has been running. The rabbit has been trying to find a chance to teach the turtle a shame before the snow.
Recently, HDU held the 50 anniversary celebration, the society's major celebrities gathered under the sand, the rabbit took the opportunity to challenge the turtle. Although the tortoise knew that the victory hope is not big, but under the pressure of public opinion, can accept the challenge.
The game is set on a straight road, the length of l meters, the rules are simple, who first reached the end of the victory.
Helpless turtle since the last victory, became a famous turtle, by some gossip magazine called "Animal Kingdom Liu Xiang", advertising constantly, at hand also has a lot of savings. In order to win the rabbit again, the turtle spent the most money to buy the most advanced weapons-"small Flying pigeon" brand electric vehicles. This car in the case of electricity can be VT1 m/s Speed "flying", but unfortunately the battery capacity is limited, each full of electricity can only travel the distance of C meters, after the foot to pedal, the turtle with the pedal speed of VT2 m/s. What's more, the turtle actually built many (n) power stations on the runway for the electric car to recharge. Where each charge takes a T-second time. Of course, turtles can choose to go or not recharge when they pass a charging station.
The game began immediately, and the hare and the tortoise with the electric electric car were standing at the starting line. Your task is to write a program, judge the turtle with the best plan to March, can win the constant speed of running rabbits.

Input
This topic contains multiple sets of tests, please handle to the end of the file. Each test consists of four rows:
The first line is a whole number L represents the total length of the runway
The second line contains three integer n,c,t, which indicates the number of charging stations, the distance the electric vehicle can travel after it has been flushed, and the time it takes to recharge each charge.
The third line is also three integer vr,vt1,vt2, respectively, indicating the speed of the rabbit running, turtle driving the speed of electric cars, turtle pedal electric car speed
The four lines contain N (n<=100) integer p1,p2...pn, respectively, representing the distance from the starting point of each charging station, where 0<p1<p2<...<pn<l
Each of these numbers is within the 32-bit integer range.

Output
When the turtle is likely to win, output a line of "What a pity rabbit!". Otherwise the output line "good job,rabbit!";
The problem data ensures that turtles and rabbits do not 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!

Author

Linle


The main topic: Turtle and Rabbit race, total length n, rabbit at a constant speed VR run, turtle ride electric car

Run, when the electric car has power to run up to C power, when the power of the time to run at VT1 speed, no electricity

waiting for the speed of VT2 run, known on the road has N charging station, give you n charging station from the starting point distance.

Do you need t-seconds per charge to ask the turtle if it is possible to win the game?

Idea: In order to calculate the distance from the next charging station for each gas station, the starting and ending points can be considered

Charging station. This will be a total of n+2 a charging station, the serial number is 0~n+1. From the first charging station to

The first n+1 charging station, calculated from the No. 0 charging station to the first J charging station in the case of full power running

The shortest time to the first I charging station dp[i]. The final answer is dp[n+1].


#include <stdio.h> #include <string.h> #include <algorithm>using namespace Std;const int INF =        100000000.0;int l,n,c,t,vr,vt1,vt2;int oil[110];d ouble dp[110],time;int Main () {while (~SCANF ("%d", &l)) {        memset (oil,0,sizeof (oil));        Memset (Dp,0,sizeof (DP));        scanf ("%d%d%d", &n,&c,&t);        scanf ("%d%d%d", &AMP;VR,&AMP;VT1,&AMP;VT2);        for (int i = 1; I <= N; i++) scanf ("%d", &oil[i]);        Oil[0] = 0;        OIL[N+1] = L;        Dp[0] = 0;            for (int i = 1; I <= n+1; i++) {Double Min = INF;            Dp[i] = Min;                for (int j = 0; J < i; J + +) {int len = oil[i]-oil[j];                if (Len < C) time = LEN*1.0/VT1;                else time = C*1.0/vt1 + (len-c) *1.0/vt2;                if (j!=0) time + = T;                    if (Min > Dp[j]+time);            Min = Dp[j]+time; }           Dp[i] = Min;        } if (Dp[n+1] > (L*1.0/VR)) printf ("Good job,rabbit!\n");    else printf ("What a Pity rabbit!\n"); } return 0;}




Hdu2059_ Turtle and Rabbit race

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.