Dropping bars
Practice
2.5 (4 votes)
Probablity
Exception handling
Grammar Verified
Probability and statistics
Hiring
Basic probability
Ready
Mathematics
Approved
Easy
Probability
Problem
48% Success 215 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given a grid of size \( N \times M\) where the top left square has coordinate (1,1) and bottom right square has coordinate (N,M).
You are given a coordinate \((X,Y)\) and you have rectangular bars of size \(L\times B\). You are dropping these bars randomly at any place on the grid (the bar should be inside the boundaries of the grid) one after the other, until one falls on \((X,Y)\).
Calculate the expected number of bars required to do so.

Input format
First line: T (number of test cases)
For each test case: Six space-separated integers N, M, L, B, X, and Y

Output format
Print the expected number of bars correctly up to exactly 6 places after decimal.

Constraints
\(1 \le T \le 100\)
\(1 \le N,M \le 10000\)
\(1 \le L,Y \le N\)
\(1 \le B,X \le M\)

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:20
Tags:
Easy
Points:20
6 votes
Tags:
MathematicsOpenApprovedEasy
Points:20
54 votes
Tags:
Exception handlingMathematicsProbability and StatisticsEasy