Pinely Round 1 (Div. 1 + Div. 2)
D
Carry Bit
Codeforces
2100
原题
← CE →
翻译中…

Let $f(x,y)$ be the number of carries of $x+y$ in binary (i. e. $f(x,y)=g(x)+g(y)-g(x+y)$, where $g(x)$ is the number of ones in the binary representation of $x$).

翻译中…

Given two integers $n$ and $k$, find the number of ordered pairs $(a,b)$ such that $0 \leq a,b \lt 2^n$, and $f(a,b)$ equals $k$. Note that for $a\ne b$, $(a,b)$ and $(b,a)$ are considered as two different pairs.

翻译中…

As this number may be large, output it modulo $10^9+7$.

翻译中…

Input

翻译中…

The only line of each test contains two integers $n$ and $k$ ($0\leq k \lt n\leq 10^6$).

翻译中…

Output

翻译中…

Output a single integer  — the answer modulo $10^9+7$.

翻译中…

Note

翻译中…

Here are some examples for understanding carries:

翻译中…

$$ \begin{aligned} &\begin{array}{r} 1_{\ \ }1_{\ \ }1\\ +\ _{1}1_{\ \ }0_{\ \ }0\\ \hline \ 1_{\ \ }0_{\ \ }1_{\ \ }1 \end{array} &\begin{array}{r} \ 1_{\ \ }0_{\ \ }1\\ +\ _{\ \ }0_{\ \ }0_{1}1\\ \hline \ 0_{\ \ }1_{\ \ }1_{\ \ }0 \end{array} & &\begin{array}{r} \ 1_{\ \ }0_{\ \ }1\\ +\ _{1}0_{1}1_{1}1\\ \hline \ 1_{\ \ }0_{\ \ }0_{\ \ }0 \end{array} \end{aligned} $$

翻译中…

So $f(7,4)=1$, $f(5,1)=1$ and $f(5,3)=3$.

翻译中…

In the first test case, all the pairs meeting the constraints are $(1,1),(1,5),(2,2),(2,3),(3,2),(4,4),(4,5),(4,6),(4,7),(5,1),(5,4),(5,6),(6,4),(6,5),(7,4)$.

翻译中…

样例

Input #1
3 1
Output #1
15
InputCopy OutputCopy
Input #2
3 0
Output #2
27
InputCopy OutputCopy
Input #3
998 244
Output #3
573035660
InputCopy OutputCopy
题目信息
题号
1761D
时间限制
1 s
内存限制
256 MB
标签
组合数学
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。