AtCoder Beginner Contest 145
D
Knight
AtCoder
⌀ 1009
原题
← CE →
翻译中…

Problem Statement

翻译中…

There is a knight - the chess piece - at the origin $(0, 0)$ of a two-dimensional grid.

翻译中…

When the knight is at the square $(i, j)$, it can be moved to either $(i+1,j+2)$ or $(i+2, j+1)$.

翻译中…

In how many ways can the knight reach the square $(X, Y)$?

翻译中…

Find the number of ways modulo $10^9 + 7$.

翻译中…

Constraints

翻译中…
  • $1 \leq X \leq 10^6$
  • $1 \leq Y \leq 10^6$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

X Y

翻译中…

Output

翻译中…

Print the number of ways for the knight to reach $(X, Y)$ from $(0, 0)$, modulo $10^9 + 7$.

翻译中…

样例

Input #1
3 3
Output #1
2
There are two ways: $(0,0) \to (1,2) \to (3,3)$ and $(0,0) \to (2,1) \to (3,3)$.
Input #2
2 2
Output #2
0
The knight cannot reach $(2,2)$.
Input #3
999999 999999
Output #3
151840682
Print the number of ways modulo $10^9 + 7$.
题目信息
题号
abc145_d
时间限制
2 s
内存限制
1024 MB

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