eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Expected Allowance

Expected Allowance

Hideyuki is allowed by his father Ujisato some \textbf{1000} yen bills every month for his pocket money. In the first day of every month, the number of bills is decided as follows. Ujisato prepares \textbf{n} pieces of \textbf{m}-sided dice and declares the cutback \textbf{k}. Hideyuki rolls these dice. The number of bills given is the sum of the spots of the rolled dice decreased by the cutback. Fortunately to Hideyuki, Ujisato promises him to give at least one bill, even if the sum of the spots does not exceed the cutback. Each of the dice has spots of \textbf{1} through m inclusive on each side, and the probability of each side is the same. In this problem, you are asked to write a program that finds the expected value of the number of given bills. \includegraphics{https://static.e-olymp.com/content/40/406eed7364aff8b16821cce9ce9478ffdaa74300.jpg} \includegraphics{https://static.e-olymp.com/content/d8/d838400f8022410ba1826db7d53c4207626080c1.jpg} For example, when \textbf{n = 2}, \textbf{m = 6} and \textbf{k = 3}, the probabilities of the number of bills being \textbf{1}, \textbf{2}, \textbf{3}, \textbf{4}, \textbf{5}, \textbf{6}, \textbf{7}, \textbf{8} and \textbf{9 }are and , respectively. Therefore, the expected value is \includegraphics{https://static.e-olymp.com/content/6f/6fa9bd8a99a57a7d35000555c009dfb82fb35466.jpg} which is approximately \textbf{4.11111111}. \InputFile The input is a sequence of lines each of which contains three integers \textbf{n}, \textbf{m} and \textbf{k} in this order. They satisfy the following conditions. \textbf{1} ≤ \textbf{n} \textbf{2} ≤ \textbf{m} \textbf{0} ≤ \textbf{k} < \textbf{nm} \textbf{nm} × \textbf{m^n} < \textbf{100000000} (\textbf{10^8}) The end of the input is indicated by a line containing three zeros. \OutputFile The output should be comprised of lines each of which contains a single decimal fraction. It is the expected number of bills and may have an error less than \textbf{10^\{−7\}}. No other characters should occur in the output.
Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
2 6 0 
2 6 3 
3 10 9 
13 3 27 
1 2008 3 
0 0 0
Выходные данные #1
7.00000000 
4.11111111 
7.71000000 
1.42902599 
1001.50298805
Источник Asia Regional Contest, Japan, AIZU, October 25-27, 2008