题解:
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int main() {
cin>>s1>>s2;
int x1=s1[0]-'a'+1,y1=s1[1]-'0',x2=s2[0]-'a'+1,y2=s2[1]-'0';
int dis=max(abs(x1-x2),abs(y1-y2));
printf("%d
",dis);
while(dis--) {
if(x1>x2 && y1>y2) {
x1--;
y1--;
printf("LD
");
continue;
}
if(x1>x2 && y1==y2) {
x1--;
printf("L
");
continue;
}
if(x1>x2 && y1<y2) {
x1--;
y1++;
printf("LU
");
continue;
}
if(x1==x2 && y1>y2) {
y1--;
printf("D
");
continue;
}
if(x1==x2 && y1<y2) {
y1++;
printf("U
");
continue;
}
if(x1<x2 && y1>y2) {
x1++;
y1--;
printf("RD
");
continue;
}
if(x1<x2 && y1==y2) {
x1++;
printf("R
");
continue;
}
if(x1<x2 && y1<y2) {
x1++;
y1++;
printf("RU
");
continue;
}
}
}