問題一覧 > 通常問題

No.1683 Robot Guidance

レベル : / AI推定難易度 : 1500 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 82
作問者 : Sumitacchan / テスター : 👑 hitonanode ygussany
お気に入りにしたユーザー ProblemId : 6820 / 自分の提出
問題文最終更新日: 2021-08-29 18:27:13
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 314 (順位表) の他の問題:

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.

  • The first command G moves it to $(x,y)=(1,0)$.
  • The next command T makes it face the positive $y$-axis direction.
  • The last command 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もしくは右上の雲マークをクリックしてアカウントを作成してください。