Practice on Toph

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

Datta's Dilemma

Limits: 1s, 90 MB

Datta, the famous sport programmer and gamer emerging from the southern part of Bangladesh is in dilemma. He needs to keep practicing to maintain both of his programming and gaming skills. When he was asked to write a problem, he came up with the following story that includes two of the legends of his favorite disciplines:

According to Wikipedia, Michael Grzesiek professionally known as Shroud, is a Canadian streamer and professional gamer.  He is known for playing  Counter-Strike: Global Offensive(CS-GO), PlayerUnknown’s Battlegrounds(PUBG), and more recently Call of Duty Black Ops 4: Blackout. He is one of the most popular gamers in gaming community and also know as The King of Reddit.

Gennady Korotkevich is a Belarusian sport programmer known as tourist who has won major international competitions since age 11, as well as numerous national competitions. His top accomplishments include six consecutive gold medals in the International Olympiad in Informatics as well as the world championship in the 2013 and 2015 International Collegiate Programming Contest World Finals. As of May 2018, Korotkevich is the highest-rated programmer at most of the online contest platforms.

One day tourist challenged Shroud in a logical game. He gave Shroud a randomly shuffled jar of coins where each coin has the value of either +1 or -1. Now Shroud can randomly take out coins one by one from the jar. Shroud is allowed to stop at any moment including the starting of the game. Shroud need to tell the expected amount of money he will get if he play the game optimally. Since Shroud is a pro gamer but not a programmer, he needs your help to get the answer.


Input contains two integers n and m (0≤n,m≤6000). Here, n is the number of coins with the value +1 and m is the number of coin with the value -1.


Output contains a single line as sample output. The expected amount that Shroud will get if he play optimally. Print six digits after the floating point.


0 3
Answer from Shroud is 0.000000
4 0
Answer from Shroud is 4.000000
4 3
Answer from Shroud is 1.657143


Login to submit