No.1683 Robot Guidance
タグ : / 解いたユーザー数 82
作問者 :
Sumitacchan
/ テスター :
👑
hitonanode
Problem Statement
A robot is placed at the origin $(x,y)=(0,0)$ of the $xy$-plane. Initially, the robot faces the positive $x$-axis direction.
You can give this robot the following $2$ types of commands.
G: The robot moves forward by $1$ in the direction it is facing.T: The robot rotates $90$ degrees counterclockwise. That is, each time this command is given, the robot's direction changes in the order positive $x$-axis → positive $y$-axis → negative $x$-axis → negative $y$-axis → positive $x$-axis → $\cdots$.
You are going to give $A$ commands G and $B$ commands T in some order
(there are $\binom{A+B}{A}$ possible command orders).
Your goal is to have the robot at $(x,y)=(X,Y)$ after all $A+B$ commands have been completed.
How many command orders achieve this goal?
Since the answer can be very large, output it modulo $10^9+7$.
Input
$A\ \ B\ \ X\ \ Y$
- $0\le A,B\le 10^6$
- $A+B>0$
- $-10^6\le X,Y\le 10^6$
- All inputs are integers.
Output
Output the number of command orders such that the robot finally ends up at $(x,y)=(X,Y)$, modulo $10^9+7$.
Sample
Sample 1
Input
2 1 1 1
Output
1
The command orders that give command G $2$ times and command T $1$ time are the $3$ orders TGG, GTG, and GGT.
Among them, only GTG leaves the robot's final position at $(x,y)=(1,1)$.
Under the command order GTG, the robot moves as follows.
G moves it to $(x,y)=(1,0)$.T makes it face the positive $y$-axis direction.G moves it to $(x,y)=(1,1)$.Sample 2
Input
1 6 0 1
Output
2
There are $2$ orders: TGTTTTT and TTTTTGT.
Sample 3
Input
998 244 35 3
Output
634338670
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。