B. Simple Game( Codeforces Round #316 (Div. 2) 简单题)

One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from1ton. Let’s assume that Misha chose numberm, and Andrew chose numbera.

Then, by using a random generator they choose a random integercin the range between1andn(any integer from1tonis chosen with the same probability), after which the winner is the player, whose number was closer toc. The boys agreed that ifmandaare located on the same distance fromc, Misha wins.

Andrew wants to win very much, so he asks you to help him. You know the number selected by Misha, and numbern. You need to determine which value ofaAndrew must choose, so that the probability of his victory is the highest possible.

More formally, you need to find such integera(1≤a≤n), that the probability thatis maximal, wherecis the equiprobably chosen integer from1ton(inclusive).

,当你见过了世界上最美丽的风景,

B. Simple Game( Codeforces Round #316 (Div. 2) 简单题)

相关文章:

你感兴趣的文章:

标签云: