No.2969 Differentiation of Laurent Monomials
Problem Statement
First, let us introduce some notation. For each pair of integers $n, m$, define the real-valued function $f_{n,m}$, whose domain is the set of all positive real numbers, by
$\displaystyle f_{n,m}(x) = n x^m $
. It can be proved that $f_{n,m}$ is differentiable for any integers $n,m$, and the derivative of $f_{n,m}$ is denoted by $f'_{n,m}$.
Click here for an explanation for those unfamiliar with differentiation. (Click to expand)
Let $f$ be a real-valued function whose domain is the set of all positive real numbers (that is, a function that takes a positive real number as its argument and takes a real value). We say that $f$ is differentiable if, for any positive real number $x_0$, the limit
$\displaystyle \lim_{x \to x_0} \frac{f(x) - f(x_0)}{x - x_0} $
converges. The value of the above limit is called the differential coefficient of $f$ at $x_0$ and is written as $f'(x_0)$. When $f$ is differentiable, a function $f'$ that returns $f'(x)$ for each positive real number $x$ is defined, and it is called the derivative of $f$.
Let $n,m$ be integers. As stated above, $f_{n,m}$ is known to be differentiable, and its derivative $f'_{n,m}$ is also known to be expressible as $m f_{n,m-1}$. To review the definitions, $f_{n,m}$ and $m f_{n,m-1}$ are real-valued functions defined on all positive real numbers, expressed as
$\displaystyle \begin{array}{rcl} \displaystyle f_{n,m}(x) &\displaystyle = &\displaystyle n x^m \\ \displaystyle m f_{n,m-1}(x) &\displaystyle = &\displaystyle mn x^{m-1} \\ \end{array} $
. Based on the above information, please answer this problem.
You are given $2$ integers $N, M$ as input.
Determine whether there exists exactly $1$ pair of integers $(n,m)$ satisfying $f'_{N,M} = f_{n,m}$, and if there exists exactly $1$ such pair, find that $(n,m)$.
Input
The input is given from standard input in $1$ line in the following format:
- The $1$st line contains $N, M$ separated by a single space.
$N$ $M$
Constraints
The input satisfies the following constraints:
- $N$ is an integer satisfying $-10^9 \leq N \leq 10^9$.
- $M$ is an integer satisfying $-10^9 \leq M \leq 10^9$.
Output
If there exists exactly $1$ pair of integers $(n,m)$ satisfying $f'_{N,M} = f_{n,m}$, print Yes on the $1$st line, and print such $n,m$ separated by a single space on the $2$nd line.
Yes $n$ $m$
Otherwise, print No on the $1$st line.
No
Print a newline at the end.
Sample
Sample 1
Input
1 1
Output
Yes 1 0
The derivative of the real-valued function $f_{N,M}(x) = 1 x^1$, whose domain is the set of all positive real numbers, can be expressed as $1 x^0$, which coincides with $f_{1,0}$. There is no pair of integers $(n,m)$ other than $(1,0)$ satisfying $f'_{N,M} = f_{n,m}$.
Sample 2
Input
4 0
Output
No
The derivative of the real-valued function $f_{N,M}(x) = 4 x^0$, whose domain is the set of all positive real numbers, is the constant function taking only the value $0$, which coincides with $f_{0,0}$ and $f_{0,1}$, among others. That is, multiple pairs of integers $(n,m)$ satisfying $f'_{N,M} = f_{n,m}$ can be taken, such as $(0,0)$ and $(0,1)$, so the claim that there exists exactly $1$ such $(n,m)$ is not true.
Sample 3
Input
-100000 -100000
Note that the input can be negative, as in this case.
Output
Yes 10000000000 -100001
Note that the answer may not fit in a 32-bit integer, as in this case.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。