JC15A - Windy Cannon

no tags 

Windy Cannon

This day is very windy, the wind blow very fast that it may be faster than the speed of cannon ball. On this windy day, Gunawan want to test his new prototype cannon, he want to shoot the target at specific location. But before doing that, he wonder how long it take for the cannon ball to hit the target. He know percisely the position of his cannon, the location of the target, the speed of his cannon ball, the speed of wind blows, and the direction of the wind, but unfortunately he forgot to bring the calculator so he ask you for help to calculate the minimum time needed for the cannon ball to hit the target or specify if it's impossible. Can you help him? You can assume that the speed of cannon ball relative to the wind is constant, all other physical effect such as gravity, air friction, temperature, magnus effect are ignored.

Input

The first line there are 4 integers and 1 character CP, TP, CBS, WS, WD denoting cannon position (m), target position (m), cannon ball speed (m/s), wind speed (m/s), and wind direction respectively.

Output

Print how many seconds the minimum time needed for cannon ball to hit the target rounded to 6 digits after decimal point.

If it's impossible for the cannon ball to hit the target, print "Impossible" without quotes.

Constraint

0 ≤ CP ≤ 100

0 ≤ TP ≤ 100

0 ≤ CBS ≤ 100

0 ≤ WS ≤ 100

if WD = 'L', it means that the wind blow into negative direction (left in catesian plane).

if WD = 'R' it means that the wind blow into positive direction (right in cartesian plane).

Sample 1

Input

2 10 2 1 L

Output

8.000000

Sample 2

Input

2 10 2 1 R

Output

2.666667

Sample 3

Input

2 10 2 3 L

Output

Impossible

Sample 4

Input

10 2 2 3 L

Output

1.600000

Sample 5

Input

50 50 12 34 R

Output

0.000000

Sample 4 Explanation

The cannon ball move at speed 2 m/s relative to the wind, so if it shoot to the right, because of the wind blowing 3 m/s to the left relative to the ground, the cannon ball move (3-2=1) m/s to the left relative to the ground and will eventually hit the target in 8 seconds, but this is not optimal, it's faster to shoot the cannon ball to the left, because the wind blowing 3 m/s to the left relative to the ground (and the same direction as the cannon ball move relative to the wind), so the cannon ball will move (3+2=5) m/s to the left relative to the ground and will eventually hit the target at (10-2)/5 = 8/5 = 1.6 seconds. We need to print the result rounded to 6 digit after decimal places, so the minimum time needed for the cannon ball to reach the target is 1.600000 seconds.


hide comments
shubham_03: 2019-01-11 18:02:11

Just focus on direction.. And rest is easy peasy

vengatesh15: 2017-10-08 17:42:28

easy one.

manjur1996: 2016-10-29 11:40:20

easy question...

rajat_kumar: 2016-08-29 21:12:07

ac ;)

Last edit: 2016-09-04 19:46:17
avisheksanvas: 2016-07-09 11:57:04

Those getting WA.
Hint -> Your output format may be wrong ;)
If you get what I mean! :p

Piyush Kumar: 2016-06-22 17:15:37

The fact that this question was set by Tjandra proves that he is only mortal:)!

kartiks025: 2016-06-08 02:24:47

@Tjandra can you please check my submission, passes all the test case and logic is also right but shows wrong answer [test_0_of_15]

(Tjandra Satria Gunawan)(曾毅昆): 2016-04-05 17:31:07

There are 16 test cases in total numbered 0..15 inclusive. Test case are not necessarily same with sample case.

tarang219: 2016-04-04 12:51:38

wrong answer [test_0_of_15]
what does it mean...plz help Tjandra

sahil_420420: 2016-03-14 14:35:53

test 0 of 15,, what does it mean? please help me tjandra submit this problem, submission id - 16506038,thank you


Added by:Tjandra Satria Gunawan
Date:2016-01-18
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU JS-MONKEY
Resource:Own Problem, used in Jolly Challenge #15