Hello Codeforces,

I would like to invite you all to participate in the **2017 JUST Programming Contest 2.0** of Jordan University of Science and Technology. The contest was originally held on 1^{st} of April, and it will launch in Codeforces Gym tomorrow; Friday 7 April 2017 13:00 UTC.

The problems were prepared by Alaa_AbuHantash (Αlαα Abu Hantash) and justHusam (Husam Musleh).

Thanks to Vendetta. (Ibraheem Tuffaha) for testing the problem set.

The duration of the contest is 4 hours, and the registration will be open 6 hours before the start of the contest.

Good luck for everyone, and I wish you all Accepted solutions.

**UPD:** Registration is currently open.

**UPD: The contest will start in 30 minutes.**

Is there gonna be editorial for the problems?

How to solve A?

Hint 1You buy Kth time from Nth shop. So you must have bought (K-1) times from some of the (N-1) shops.

Hint 2P(success) = p, P(Failure) = (1.0 — p). We need to find success (K) times in (N) shops, with a compulsion that Kth must be from Nth shop.

Hint 3The answer is choose(N — 1, K — 1) * [ P(fail)^(N-K) ] * [ P(success)^(K) ]

Hi there,

I tried approaching the problem with DP ... and I didn't see the O(1) formula ! Great work... I understood how to computer the probability. But, I'm struggling with getting the answer into the output format the question is asking.

I know how to compute the answer in terms of getting probability as a floating point number.

Can you explain ... given a floating point number f, how to get a fraction p/q, and from there get a y such that y*q = p (mod 1e9 + 7) ?

Thanks.

You can get the floating number x using string. The multi x 1000. So p/q = x*1000/1000.

I didn't understand. Can you elaborate ?

I think your question's answer is calculating the probability in inverse element. My poor English.

No Problem ! Can you just write the piece of code that does what you say ? Then, i can understand. Or maybe some Wikipedia links ... I appreciate your help. By inverse, do you mean inverse in the modulo group 1e9 + 7 ?

Yes.Maybe my words is this p / q can be changed to p * inverse of q.

If p is the inverse of q, does it mean that

pq = 1 (mod 1e9 + 7) ?

This is what I understood.

How do I convert the floating point number to this p/q form ? Please help.

How to solve J?