Samu and Shooting Game
Practice
3.8 (63 votes)
Dynamic programming
Easy
Open
Two dimensional
Problem
19% Success 5873 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Samu is playing a shooting game in play station. There are two apples to aim in this shooting game. Hitting first apple will provide her X points and hitting second apple will provide her Y points. And if she misses the apple she chose to hit, she wont get any point.

Now she is having N coins and each shoot will cost her 1 coin and she needs to score at least W points to win the game.

Samu don't like to loose at any cost. At each turn, she has two choices. The choices include:-

  • Hitting first apple with probability P1 percent. However, she might miss it with probability (1-P1) percentage.
  • Hitting second apple with probability P2 percent. However, she might miss it with probability (1-P2) percentage.

She would like to know what is the maximal expected probability(as a percentage b/w 0 and 100) of winning the shooting game.

Input Format:
First line contains the number of test cases T.
Each test case consists of six space separated integers of the form X Y N W P1 P2 as described in the statement.

Output Format:
For each test case, print the result as described above in a separate line.

Note:
Choosing to hit any apple is entirely her choice. Both are independent events meaning P1 + P2 may/may not exceed 100.
Output must contain 6 digits after decimal.

Constraints:
1 ≤ T ≤ 10
1 ≤ X,Y ≤ 10
1 ≤ N,W ≤ 103
0 ≤ P1,P2 ≤ 100

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
13 votes
Tags:
Dynamic ProgrammingEasyTwo dimensional
Points:30
5 votes
Tags:
CombinatoricsDynamic ProgrammingEasy
Points:30
22 votes
Tags:
AlgorithmsDynamic ProgrammingEasyString ManipulationTwo dimensional