No.2188 Integer Sequence Coin Toss Game
Problem Statement
You are given non-negative integers $N,M$ as input.
First, let us review the notation and terminology. We define $0^0$ as $1$. Here, an infinite sequence of integers is simply called an integer sequence.
For an integer sequence $a$ and a non-negative integer $m$, $a_m$ denotes the $m$-th element of $a$ in $0$-based indexing, that is, the $1+m$-th element of $a$. In other words, using the ellipsis "$\ldots$", the integer sequence $a$ can be written as
$\displaystyle (a_0, a_1, a_2, a_3, \ldots ) $
.
Whenever we speak of coin tosses, the trials are independent, and in every trial the probability of heads and the probability of tails are both $\frac{1}{2}$.
Coin Toss Loving Bot is, as you know, a bot that loves coin tosses.
For each integer sequence $a$, Coin Toss Loving Bot devised the following single-player game:
- First, the player chooses any non-negative integer $x$.
- Next, the player tosses a coin $x$ times; let $m$ be the number of times heads comes up.
- Finally, the player earns $a_m$ points.
Let us call the game constructed in this way from an integer sequence $a$ "the integer sequence coin toss game associated with $a$".
Now, let us get to the main subject.
One day, Coin Toss Loving Bot wondered how much information about the integer sequence $a$ can be recovered from information about the expected score in the integer sequence coin toss game associated with $a$.
Determine whether there exists an integer sequence $a$ satisfying "for any non-negative integer $X$, the expected score when choosing $X$ as $x$ in the integer sequence coin toss game associated with $a$ is $2^{-X} X^N$", and if one exists, find $1$ possible value of $a_M$ for such an integer sequence $a$.
Input
The input is given from standard input in the following format:
$N$ $M$
Constraints
The input $N,M$ satisfies the following constraints:
- $N$ is a non-negative integer at most $15$
- $M$ is a non-negative integer at most $10^9$
Output
If there exists an integer sequence $a$ such that the expected score when choosing a non-negative integer $X$ as $x$ in the integer sequence coin toss game associated with $a$ is $2^{-X} X^N$, print $1$ possible value of $a_M$ for such an integer sequence $a$ on $1$ line; if none exists, print NaN.
This problem uses a special judge. Even if the correct answer is not limited to $1$ possibility, print only $1$ of them.
Also, due to judging constraints, your output must be at most $100$ characters.
Print a newline at the end.
Sample
Sample 1
Input
1 1
Output
1
For each non-negative integer $m$, let
$\displaystyle a_m := \left\{ \begin{array}{ll} 1 & (m = 1) \\ 0 & (m \neq 1) \end{array} \right. $
thereby defining the integer sequence $a$. In the integer sequence coin toss game associated with $a$, for any non-negative integer $X$, the expected value of the player's score when choosing $X$ as $x$ is
$\displaystyle \displaystyle \sum_{m = 0}^{X} (\textrm{probability of getting } m \textrm{ heads}) \times a_m = \frac{X}{2^X} \times a_1 = 2^{-X} X = 2^{-X} X^N $
. Therefore, the value of $a_M = a_1$ for this integer sequence $a$, which is $1$, is $1$ of the correct answers.
Sample 2
Input
2 1
Output
1
For each non-negative integer $m$, let
$\displaystyle a_m := \left\{ \begin{array}{ll} 2 & (m = 2) \\ 1 & (m = 1) \\ 0 & (m \neq 1,2) \end{array} \right. $
thereby defining the integer sequence $a$. In the integer sequence coin toss game associated with $a$, for any non-negative integer $X$, the expected value of the player's score when choosing $X$ as $x$ is
$\displaystyle \begin{array}{rcl} \displaystyle \sum_{m = 0}^{X} (\textrm{probability of getting } m \textrm{ heads}) \times a_m &\displaystyle = &\displaystyle \frac{X(X-1)}{2^{X+1}} \times a_2 + \frac{X}{2^X} \times a_1 \\ &\displaystyle = &\displaystyle \frac{X(X-1)}{2^X} + \frac{X}{2^X} \\ &\displaystyle = &\displaystyle 2^{-X} X^2 \\ &\displaystyle = &\displaystyle 2^{-X} X^N \end{array} $
. Therefore, the value of $a_M = a_1$ for this integer sequence $a$, which is $1$, is $1$ of the correct answers.
Sample 3
Input
3 1
Output
1
For each non-negative integer $m$, let
$\displaystyle a_m := \left\{ \begin{array}{ll} 6 & (m = 3) \\ 6 & (m = 2) \\ 1 & (m = 1) \\ 0 & (m \neq 1,2,3) \end{array} \right. $
thereby defining the integer sequence $a$. In the integer sequence coin toss game associated with $a$, for any non-negative integer $X$, the expected value of the player's score when choosing $X$ as $x$ is
$\displaystyle \begin{array}{rcl} \displaystyle \sum_{m = 0}^{X} (\textrm{probability of getting } m \textrm{ heads}) \times a_m &\displaystyle = &\displaystyle \frac{X(X-1)(X-2)}{2^{X+1} \times 3} \times a_3 + \frac{X(X-1)}{2^{X+1}} \times a_2 + \frac{X}{2^X} \times a_1 \\ &\displaystyle = &\displaystyle \frac{X(X-1)(X-2)}{2^X} + \frac{3X(X-1)}{2^X} + \frac{X}{2^X} \\ &\displaystyle = &\displaystyle 2^{-X} X^3 \\ &\displaystyle = &\displaystyle 2^{-X} X^N \end{array} $
. Therefore, the value of $a_M = a_1$ for this integer sequence $a$, which is $1$, is $1$ of the correct answers.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。