Codeforces Round 190 (Div. 1)
A
Ciel and Robot
Codeforces
1700
原题
←B →
翻译中…

Fox Ciel has a robot on a 2D plane. Initially it is located in (0, 0). Fox Ciel code a command to it. The command was represented by string $*s*$. Each character of $*s*$ is one move operation. There are four move operations at all:

翻译中…
  • 'U': go up, (x, y) $→$ (x, y+1);
  • 'D': go down, (x, y) $→$ (x, y-1);
  • 'L': go left, (x, y) $→$ (x-1, y);
  • 'R': go right, (x, y) $→$ (x+1, y).
翻译中…

The robot will do the operations in $*s*$ from left to right, and repeat it infinite times. Help Fox Ciel to determine if after some steps the robot will located in $(*a*, *b*)$.

翻译中…

Input

翻译中…

The first line contains two integers $*a*$ and $*b*$, ($- 10^{9} ≤ *a*, *b* ≤ 10^{9}$). The second line contains a string $*s*$ ($1 ≤ |*s*| ≤ 100$, $*s*$ only contains characters 'U', 'D', 'L', 'R') — the command.

翻译中…

Output

翻译中…

Print "Yes" if the robot will be located at $(*a*, *b*)$, and "No" otherwise.

翻译中…

Note

翻译中…

In the first and second test case, command string is "RU", so the robot will go right, then go up, then right, and then up and so on.

翻译中…

The locations of its moves are (0, 0) $→$ (1, 0) $→$ (1, 1) $→$ (2, 1) $→$ (2, 2) $→$ $...$

翻译中…

So it can reach (2, 2) but not (1, 2).

翻译中…

样例

Input #1
2 2
RU
Output #1
Yes
InputCopy OutputCopy
Input #2
1 2
RU
Output #2
No
InputCopy OutputCopy
Input #3
-1 1000000000
LRRLU
Output #3
Yes
InputCopy OutputCopy
Input #4
0 0
D
Output #4
Yes
InputCopy OutputCopy
题目信息
题号
321A
时间限制
1 s
内存限制
256 MB
标签
二分
模拟
数学

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