DCP-356: Cheat the Lottery Back to All Problems

Medium Math > Probability/Expected Value


Interestingly the probability of winning 1st prize in the lottery is higher than the probability of winning 10th prize, if you don't win the any prize from 2nd to 10th. Minas buys a lottery ticket and he knows **N** people buy lottery including him. He knows a magic trick, which he can use to win a lottery prize. But he can only use the magic if the winning probability is greater than or equal to **P**. When prize giving is occurring, people getting the prize and his winning probability are getting higher and when his winning probability is greater than or equal to **P**, he does the magic and win a prize. Now he will give you the number of people buying the lottery is **N** and probability is **P**. You need to tell minimum number of prize organizer needs to declare so that Minas can use his magic trick to win a prize. Input: ------ Input starts with an integer **T (1<=T<=100000)**, denoting the number of test cases. Each case contains an integer **N** denoting the number of people buy lottery ticket and **p** and **q** where **p/q = P**. **1 ≤ N, p, q ≤ 1000000000** **0 < p/q <= 1** Output: ------- For each case of input, output the minimum number of prize need to declare so that he can use his magic trick to win a prize. Sample Input ------------ 2 1 1 1 3 1 2 Sample Output ------------- 1 2


Problem Setter:

MD Musfiqur Rahman Sanim

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 2.00
Go 2.00
Java 2.00
JavaScript 2.00
Objective-C 2.00
Perl 2.00
PHP 2.00
Python 2.00
Python3 2.00
Ruby 2.00
VB.Net 2.00

Problem Stats

36/225

Solve/Submission

Ranking

# User Language Timing
01 ____ Cpp 0.05s
02 feodorv C 0.05s
03 Zeronfinity Cpp 0.06s
04 sahedsohel Cpp 0.06s
05 tariqiitju Cpp 0.06s
06 moshiur_cse15 Cpp 0.07s
07 abinash Cpp 0.08s
08 ovis96 Cpp 0.08s
09 rubabredwan Cpp14 0.08s
10 Hawk Cpp 0.08s
11 ShockProof Cpp 0.08s
12 Reayz Cpp 0.08s
13 sdpsarker88 Cpp 0.08s
14 sazal_dev Cpp 0.08s
15 adamantium Cpp 0.09s
16 ssavi Cpp 0.09s
17 mamun4122 Cpp 0.09s
18 Ihtiaz Cpp 0.09s
19 CLown1331 Cpp14 0.11s
20 Mohtasim Cpp 0.12s
21 BishalG Cpp 0.23s
22 ashraful_afruz Cpp 0.27s
23 SakibAlamin Cpp14 0.29s
24 Double_O Cpp 0.82s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support