 New update is available. Click here to update.

# Mohan and Magic Boots

Contributed by
Jaypal Mudaliyar
Last Updated: 23 Feb, 2023
Medium 0/80
Avg time to solve 40 mins
Success Rate 70 % Share 0 upvotes

## Problem Statement

#### Being his friend he asked you to help him to calculate the probability to reach point ‘N’ and help him decide if it's helpful to pick up the boots or not. If the probability is strictly greater than ‘X/100’ you say ‘1’ or else you say ‘0’. Can you help him?.

##### EXAMPLE :
``````Input: ‘N’ = 2, ‘P' = 30, ‘X’ = 29

Output: 1
In this case,
The probability to reach point ‘2(=N)’ while wearing the magic boots is
‘P/100’ = 30/100 = 0.30 i.e. 0.30 > (‘X/100’ = 29/100 = 0.29). Hence the output will be ‘1’.
``````
Detailed explanation ( Input/output format, Notes, Images ) ##### Constraints :
``````1 <= ‘T’ <= 10
1 <= ‘N’ <= 10^5
1 <= ‘P’ <= 100
1 <= ‘X’ <= 100
It is guaranteed that sum of ‘N’ over all test cases is <= 10^5
Time Limit: 1 sec
``````
##### Sample Input 1 :
``````2
3 17 12
4 16 10
``````
##### Sample Output 1 :
``````1
0
``````
##### Explanation Of Sample Input 1 :
``````For the first test case, the probability of reaching point ‘3(=N)’ by wearing magic boots is ‘(100-P)/100’ = 83/100 = 0.83, which is greater than ‘X/100’ = 12/100 = 0.12.

Hence, the output will be: 1

For the second test case, the probability of reaching point ‘4(=N)’ by wearing magic boots and first getting teleported to point ‘2’ with a probability ‘P/100’ and then again getting teleported to point ‘4’ with a probability ‘P/100’ i.e. overall probability is ‘(P/100)*(P/100)’ = (16/100)*(16/100) = 256/10000 = 0.0256, which is less than ‘X/100’ = 10/100 = 0.10.

Hence, the output will be: 0
``````
##### Sample Input 2 :
``````2
5 20 31
10 40 36
``````
##### Sample Output 2 :
``````1
0
``````  Auto Console