[ACM] hdu 4418 Time travel (Gaussian deyuan expectation), hdu4418

Source: Internet
Author: User

[ACM] hdu 4418 Time travel (Gaussian deyuan expectation), hdu4418

Time travel


Problem Description
Agent K is one of the greatest agents in a secret organization called Men in Black. once he needs to finish a mission by traveling through time with the Time machine. the Time machine can take agent K to some point (0 to n-1) on the timeline and when he gets to the end of the time line he will come back (For example, there are 4 time points, agent K will go in this way 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1,...). But when agent K gets into the Time machine he finds it has broken, which make the Time machine can't stop (Damn it !). Fortunately, the time machine may get recovery and stop for a few minutes when agent K arrives at a time point, if the time point he just arrive is his destination, he'll go and finish his mission, or the Time machine will break again. the Time machine has probability Pk % to recover after passing k time points and k can be no more than M. we guarantee the sum of Pk is 100 (Sum (Pk) (1 <= k <= M) = 100 ). now we know agent K will appear at the point X (D is the direction of the Time machine: 0 represents going from the start of the timeline to the end, on the contrary 1 represents going from the end. if x is the start or the end point of the time line D will be-1. agent K want to know the expectation of the amount of the time point he need to pass before he arrive at the point Y to finish his mission.
If finishing his mission is impossible output "Impossible! "(No quotes) instead.
 
InputThere is an integer T (T <= 20) indicating the cases you have to solve. the first line of each test case are five integers N, M, Y, X. D (0 <N, M <= 100, 0 <= X, Y <100 ). the following M non-negative integers represent Pk in percentile.
 
OutputFor each possible scenario, output a floating number with 2 digits after decimal point
If finishing his mission is impossible output one line "Impossible! "
(No quotes) instead.
 
Sample Input
24 2 0 1 050 504 1 0 2 1100
 
Sample Output
8.142.00
 
Source2012 ACM/ICPC Asia Regional Hangzhou Online solution:

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.