DAPC19-062.Deceptive Dice
Medium · 1 s · 256 MB
- icpc
- dapc
- 2019
Recently your town has been infested by swindlers who convince unknowing tourists to play a simple dice game with them for money. The game works as follows: given is an -sided die, whose sides have pips, and a positive integer . You then roll the die, and then have to make a choice. Option 1 is to stop rolling. Option 2 is to reroll the die, with the limitation that the die can only be rolled times in total. Your score is the number of pips showing on your final roll.
Obviously the swindlers are better at this game than the tourists are. You, proud supporter of the Battle Against Probabilistic Catastrophes, decide to fight this problem not by banning the swindlers but by arming the tourists with information.
You create pamphlets on which tourists can find the maximum expected score for many values of and . You are sure that the swindlers will soon stop their swindling if the tourists are better prepared than they are!
The layout of the flyers is done, and you have distribution channels set up. All that is left to do is to calculate the numbers to put on the pamphlet.
Given the number of sides of the die and the number of times you are allowed to roll, calculate the expected (that is, average) score when the game is played optimally.
Giriş formatı
• A single line with two integers , the number of sides of the die, and , the number of times the die may be rolled.
Çıxış formatı
Output the expected score when playing optimally. Your answer should have an absolute or relativ eerror of at most .
Qeyd
Source: Delft Algorithm Programming Contest 2019 · Author: Mees de Vries · License: CC BY-SA 4.0 · Original: https://dapc.wisv.ch · Statement adapted for AlgoLens and shared under the same license.
Nümunələr
Giriş #1
1 1
Çıxış #1
1
Giriş #2
2 3
Çıxış #2
1.875
Giriş #3
6 2
Çıxış #3
4.25
Giriş #4
8 9
Çıxış #4
7.268955230712891