http://codeforces.com/contest/3/problem/A
思路简单的模拟。。。
拼手速,力保1A
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define ll long long
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
#define ll long long
int main()
{
char tmp;
int x;
while(cin>>tmp>>x)
{
int y = (int)(tmp-'a');
int ye, xe;
cin>>tmp>>xe;
ye = (int)(tmp-'a');
int cnt = 0;
swap(x, y);
swap(xe, ye);
string ans[105];
//cout<<x<<' '<<y<<' '<<xe<<' '<<ye<<endl;
while(x != xe || ye != y)
{
if(xe > x && ye == y)
{
ans[++ cnt] = "R";
x ++;
}
else if(xe < x && ye == y)
{
ans[++ cnt] = "L";
x --;
}
else if(xe == x && ye < y)
{
ans[++ cnt] = "D";
y --;
}
else if(xe == x && y < ye)
{
ans[++ cnt] = "U";
y ++;
}
else if(x < xe && y < ye)
{
ans[++ cnt] = "RU";
x ++;
y ++;
}
else if(x < xe && y > ye)
{
ans[++ cnt] = "RD";
x ++;
y --;
}
else if(x > xe && y < ye)
{
ans[++ cnt] = "LU";
x --;
y ++;
}
else
{
ans[++ cnt] = "LD";
x --;
y --;
}
}
cout<<cnt<<endl;
for(int i = 1; i <= cnt; i ++)
cout<<ans[i]<<endl;
}
return 0;
}