FUNPROB - Yanu in Movie theatre

Yanu is a great fan of Harry Potter. So on the day of the movie release, Yanu rushes to the movie theatre to watch the movie. On the release of the 6th movie, on reaching the theatre she found a long queue for tickets already. As the distribution was about to start, the ticket counter did not have any change to start with. There are N+M people in queue, where N have Rs 10.00 and M have Rs 5.00. The ticket costs Rs 5.00.

Now Yanu is math geek too, now she wonders What is the probability that the theatre can always provide change.


Each line contain N and M, separated by a space, End of Input is marked by 0 0 which should not be processed. Both N and M fits in integer range.


For each input, output the respective probability up to 6 decimal digits.


1 0
0 1
41 41
0 0


hide comments
infinity_98: 2020-07-09 09:25:43

is this probem can be solved by catalan number concept?

divyansh15: 2020-05-14 12:48:26

the solution to the problem:
Read the "Variant: ties allowed" section

pratyushgoel99: 2020-01-02 18:55:31

how is this easy ? i could'nt come up with the formula :(

pandey101299: 2019-03-22 07:02:52

So easy just observe the pattern

masterchef2209: 2019-03-06 22:01:08

if anyone solved it using formula. can you please post in detail, how you arrived at the formula?

masterchef2209: 2019-03-06 21:51:46

damn i suck at math :(

sanyam19: 2018-01-08 22:39:50

it was n easy problem.... :)
just observation will help u

trijeet: 2017-09-20 00:28:49

Use printf("%lf",ans) for ordering. Got WA without it.

abhi2296: 2016-05-09 17:05:20

my 50th!!! Easy!

azam_9: 2016-01-31 06:57:58

my in 1 go...<3

Added by:Hemant Verma
Time limit:0.506s
Source limit:1024B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:A Classical Probability Problem