有 个问题,其中有 个问题的答案是 YES
, 个问题的答案是 NO
。当你回答一个问题之后,会知道这个问题的答案,求最优策略下期望对多少。
答案对 取模。
You are participating in a quiz with questions and Yes/No answers.
It's known in advance that there are questions with answer Yes and questions with answer No, but the questions are given to you in random order.
You have no idea about correct answers to any of the questions. You answer questions one by one, and for each question you answer, you get to know the correct answer immediately after answering.
Suppose you follow a strategy maximizing the expected number of correct answers you give.
Let this expected number be , an irreducible fraction. Let . It can be proven that a unique integer between and exists such that modulo , and it is equal to modulo , where is the modular inverse of . Find .
Input is given from Standard Input in the following format:
Let be the expected number of correct answers you give if you follow an optimal strategy, represented as an irreducible fraction. Print modulo .
1 1
499122178
There are two questions. You may answer randomly to the first question, and you'll succeed with 50% probability. Then, since you know the second answer is different from the first one, you'll succeed with 100% probability.
The expected number of your correct answers is . Thus, , , (modulo ), and (again, modulo ).
2 2
831870297
The expected number of your correct answers is .
3 4
770074220
The expected number of your correct answers is .
10 10
208827570
42 23
362936761