CF321A.Ciel and Robot

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 ss . Each character of ss 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 ss 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)(a,b) .

输入格式

The first line contains two integers aa and bb , ( 109<=a,b<=109-10^{9}<=a,b<=10^{9} ). The second line contains a string ss ( 1<=s<=1001<=|s|<=100 , ss only contains characters 'U', 'D', 'L', 'R') — the command.

输出格式

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

输入输出样例

  • 输入#1

    2 2
    RU
    

    输出#1

    Yes
    
  • 输入#2

    1 2
    RU
    

    输出#2

    No
    
  • 输入#3

    -1 1000000000
    LRRLU
    

    输出#3

    Yes
    
  • 输入#4

    0 0
    D
    

    输出#4

    Yes
    

说明/提示

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

首页