题库练习 Carry Bit
← 上一题 下一题 →

A15505 | Carry Bit

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

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 < 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$ .

输入格式

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

输出格式

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

输入输出样例

输入 #1
3 1
输出 #1
15
输入 #2
3 0
输出 #2
27
输入 #3
998 244
输出 #3
573035660
C++ 编辑器
输入
输出