Company: Landeed IIT Kharagpur
Difficulty: medium
Probability of Divisibility by 12 Problem Description You are playing a game with a fair S -sided die whose faces are numbered 1, 2, ..., S . Every face has the same probability 1 / S of landing face up, and the rolls are independent of one another. You roll the die over and over. After every roll you look at the cumulative product of all of the numbers rolled so far, and the game stops the moment that product becomes divisible by a fixed integer D . Given S , D and a roll number K , report the probability that the game stops on exactly the K -th roll. In other words, report the probability that the cumulative product is not divisible by D after rolls 1, 2, ..., K - 1 and is divisible by D after roll K . Input Format The input consists of a single line containing three space-separated integers S , D and K . Output Format Print the probability on a single line, rounded to exactly 10 digits after the decimal point . Rounding is to nearest, and a value that falls exactly halfway between t