<gh_stars>0
{
	"link":"http://community.topcoder.com/stat?c=problem_statement&pm=3510&rd=6527",
	"statement":"Consider a function randomInt(integer N) that takes an integer N and returns an integer uniformly at random in the range 0 to N-1. If that function is nested, as in randomInt(randomInt(N)), the probability distribution changes, and some numbers are more likely than others. Given an int <b>nestings</b> defining the number of times the function is nested (1 indicates randomInt(N), 2 indicates randomInt(randomInt(N)), and so on), an int <b>N</b> and an int <b>target</b>, return the probability that the result of <b>nestings</b> nested calls to randomInt with the parameter <b>N</b> will result in <b>target</b>. ",
	"notes":[
		{
			"order":1,
			"val":"Calling randomInt(0) causes an error to occur, and hence can never cause an outcome of ."
		},
		{
			"order":2,
			"val":"Your return must have a relative or absolute error less than 1E-9."
		}
	],
	"definition":[
		{
			"definitionKey":"Class:",
			"definitionVal":"NestedRandomness",
			"order":1
		},
		{
			"definitionKey":"Method:",
			"definitionVal":"probability",
			"order":2
		},
		{
			"definitionKey":"Parameters:",
			"definitionVal":"int, int, int",
			"order":3
		},
		{
			"definitionKey":"Returns:",
			"definitionVal":"double",
			"order":4
		},
		{
			"definitionKey":"Method signature:",
			"definitionVal":"double probability(int N, int nestings, int target)",
			"order":5
		}
	],
	"examples":[
		{
			"expect":"2",
			"id":0,
			"input":"5",
			"note":"There are 3 ways of ending up with a 1 after calling randomInt(randomInt(5)). The inner call can result in a 4, 3, or a 2. Each of these possibilities occurs with a probability of 1/5. The probabilities of achieving a 1 with each of those results are 1/4, 1/3, and 1/2, respectively. This gives us a final probability of (1/5)*(1/4+1/3+1/2) = 13/60.",
			"order":1
		},
		{
			"expect":"4",
			"id":0,
			"input":"10",
			"order":2
		},
		{
			"expect":"10",
			"id":0,
			"input":"1000",
			"order":3
		}
	],
	"constraints":[
		{
			"order":1,
			"val":"N will be between 1 and 1000, inclusive."
		},
		{
			"order":2,
			"val":"nestings will be between 1 and 10, inclusive."
		},
		{
			"order":3,
			"val":"target will be between 0 and N-nestings, inclusive."
		}
	]
}