机器人必然走n个循环+1段
所以只要暴力枚举段
设到第i步时机器人在(xi,yi)
则xt=t*xn+xi yt=t*yn+yi
乱搞即可……
过了Present Test(好激动!数回Div2 只做2题的菜)
结果Final Wa 了……
//我是白痴……
经鉴定,是我68行把||打成了&&……
我的Div 1 啊!!!!!!!!
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<iostream>
#include<cmath>
#include<cctype>
#include<ctime>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Lson (x<<1)
#define Rson ((x<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,127,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define INF (2139062143)
#define F (100000007)
#define MAXN (50000+10)
long long mul(long long a,long long b){return (a*b)%F;}
long long add(long long a,long long b){return (a+b)%F;}
long long sub(long long a,long long b){return (a-b+(a-b)/F*F+F)%F;}
typedef long long ll;
ll a,b;
int n;
char s[1000];
int x[1000],y[1000];
int main()
{
// freopen("robot.in","r",stdin);
// freopen(".out","w",stdout);
cin>>a>>b;
scanf("%s",s+1);n=strlen(s+1);
x[0]=y[0]=0;
bool bo=0;
For(i,n)
{
if (s[i]=='R') x[i]=x[i-1]+1,y[i]=y[i-1];
if (s[i]=='L') x[i]=x[i-1]-1,y[i]=y[i-1];
if (s[i]=='U') x[i]=x[i-1],y[i]=y[i-1]+1;
if (s[i]=='D') x[i]=x[i-1],y[i]=y[i-1]-1;
if (x[i]==a&&y[i]==b) bo=1;
}
if (bo==1)
{
cout<<"Yes"<<endl;
return 0;
}
Rep(i,n+1)
{
int t1=a-x[i],t2=b-y[i];
if (t1!=0&&x[n]==0) continue;
if (t2!=0&&y[n]==0) continue;
if (x[n]==0||y[n]==0)
{
bool bo1=0,bo2=0;
if (x[n]==0) bo1=1;
if (y[n]==0) bo2=1;
if (bo1&&!bo2) if (t2%y[n]==0&&t2/y[n]>=0) {cout<<"Yes"<<endl;return 0;} else continue;
if (!bo1&&bo2) if (t1%x[n]==0&&t1/x[n]>=0) {cout<<"Yes"<<endl;return 0;} else continue;
if (!x[i]&&!y[i]) {cout<<"Yes"<<endl;return 0;} else continue;
}
if (t1%x[n]||t2%y[n]) continue;
t1/=x[n],t2/=y[n];
if (t1<0||t2<0||t1^t2) continue;
cout<<"Yes"<<endl;
return 0;
}
cout<<"No"<<endl;
return 0;
}