Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Once Upon a Time in Dhaka

By ihumaunkabir · Limits 1s, 256 MB

Dhaka is one of the mega cities of Bangladesh. At different times, Dhaka was entitled differently by poets, lyricists, and artists. The bus is one of the most used public transport here in Dhaka. A daily passenger who travels on a bus has to struggle to get in a bus amidst of crowd. When it comes to traveling through a bus, there is a phenomenon called ‘window dilemma’ where two passengers of front and back seats exchange hot words for their share of the empty space in the window.

You may know that the window of the bus has a sliding glass that slides horizontally. The horizontal length of the window is WW and the horizontal length of the sliding glass is GG. Your task is to slide the glass and distribute equal empty space to both passengers.


The first line of input consists of an integer T(1T1000)T ( 1 \leq T \leq 1000 ) denoting the number of cases. The next TT lines contain two integers W(2<W1000)W ( 2 < W \leq 1000) and G(1G<W)G ( 1 \leq G < W) respectively indicating the horizontal length of the window and the horizontal length of the sliding glass.


Print the length of the empty space of the window each passenger gets. The answer should be accurate at least up to four decimal places.


6 2



97% Solution Ratio

Uosmoy383Earliest, 1M ago

coffeeloverFastest, 0.0s

Uosmoy383Lightest, 131 kB

anonyo.akandShortest, 70B


Login to submit


The problem is pretty straightforward, we can calculate the empty space for each passenger by d = ( ...

Toph uses cookies. By continuing you agree to our Cookie Policy.