The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose heart, because he has business of national importance. For example, he has to pay an official visit to square t. As the king is not in habit of wasting his time, he wants to get from his current position s to square t in the least number of moves. Help him to do this.

In one move the king can get to the square that has a common side or a common vertex with the square the king is currently in (generally there are 8 different squares he can move to).

Input

The first line contains the chessboard coordinates of square s, the second line — of square t.

Chessboard coordinates consist of two characters, the first one is a lowercase Latin letter (from a to h), the second one is a digit from 1 to 8.

Output

In the first line print n — minimum number of the king's moves. Then in n lines print the moves themselves. Each move is described with one of the 8: L, R, U, D, LU, LD, RU or RD.

L, R, U, D stand respectively for moves left, right, up and down (according to the picture), and 2-letter combinations stand for diagonal moves. If the answer is not unique, print any of them.

Examples

Input
a8
h1
Output
7
RD
RD
RD
RD
RD
RD
RD     cf此题地址http://codeforces.com/problemset/problem/3/A     这里学到了string这个东西。比如,string a; a[0]="adasdasd",第一次知道还有这种操作,一位存一个字符串,那么就简单多了。
    那么使用while模拟就好了,一直接近终点。肯定尽量先斜着走。while根据两者的位置分成好几种情况。根据ASCLL码,直接++,--就好了,不用再变成数字了。string s。s[0],s[1]直接++--就好了,直到等于e[0],e[1]。
使用一个tot来计数,此为总步数。
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
string map[];
string s,e;
int main()
{
int tot=;
cin>>s;
cin>>e;
while(s[]<e[]&&s[]<e[])
{
s[]++;s[]++;
map[tot++]="RU";
}
while(s[]<e[]&&s[]>e[])
{
s[]++;s[]--;
map[tot++]="RD";
}
while(s[]>e[]&&s[]<e[])
{
s[]--;s[]++;
map[tot++]="LU";
}
while(s[]>e[]&&s[]>e[])
{
s[]--;s[]--;
map[tot++]="LD";
}
while(s[]==e[]&&s[]>e[])
{
s[]--;
map[tot++]="D";
}
while(s[]==e[]&&s[]<e[])
{
s[]++;
map[tot++]="U";
}
while(s[]==e[]&&s[]<e[])
{
s[]++;
map[tot++]="R";
}
while(s[]==e[]&&s[]>e[])
{
s[]--;
map[tot++]="L";
}
cout<<tot<<endl;
for(int i=;i<tot;i++)
cout<<map[i]<<endl;
}

A - Shortest path of the king (棋盘)的更多相关文章

  1. Codeforces Beta Round #3 A. Shortest path of the king 水题

    A. Shortest path of the king 题目连接: http://www.codeforces.com/contest/3/problem/A Description The kin ...

  2. Codeforces-A. Shortest path of the king(简单bfs记录路径)

    A. Shortest path of the king time limit per test 1 second memory limit per test 64 megabytes input s ...

  3. 3A. Shortest path of the king

    给你一个的棋盘, 问:从一个坐标到达另一个坐标需要多少步? 每次移动可以是八个方向.   #include <iostream> #include <cmath> #inclu ...

  4. Codeforces Beta Round #3 A. Shortest path of the king

    标题效果: 鉴于国际棋盘两点,寻求同意的操作,是什么操作的最小数量,在操作过程中输出. 解题思路: 水题一个,见代码. 以下是代码: #include <set> #include < ...

  5. Shortest path of the king

    必须要抄袭一下这个代码 The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose h ...

  6. CF3A Shortest path of the king

    The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose heart, becaus ...

  7. node搜索codeforces 3A - Shortest path of the king

    发一下牢骚和主题无关: 搜索,最短路都可以     每日一道理 人生是洁白的画纸,我们每个人就是手握各色笔的画师:人生也是一条看不到尽头的长路,我们每个人则是人生道路的远足者:人生还像是一块神奇的土地 ...

  8. CF3A 【Shortest path of the king】

    一句话题意:在8 * 8的棋盘上,输出用最少步数从起点走到终点的方案 数据很小,可以广搜无脑解决 定义数据结构体 struct pos{ int x,y,s; //x.y表示横纵坐标,s表示步数 ]; ...

  9. Codeforces 3A-Shortest path of the king(BFS打印路径)

    A. Shortest path of the king time limit per test 1 second memory limit per test 64 megabytes input s ...

随机推荐

  1. 一、Vue环境搭建及基础用法

    一.项目初始化及安装 官网:https://cn.vuejs.org/ 1.1安装及运行项目步骤 1.安装vue-cli(-g=-global) npm install -g vue-cli cnpm ...

  2. EditText标签的使用

    前文: 介绍EditText的使用,这个是文本输入控件,用来输入文本内容 使用: EditText继承TextView所以TextView的东西EditText都可以使用 text:显示文本 text ...

  3. linux扩容空间,再扩容文件系统

    Linux磁盘空间进行扩容 参考博客 http://blog.csdn.net/dingchenxixi/article/details/50986472 http://blog.sina.com.c ...

  4. GNS3 模拟icmp分片不可达

    R1 : conf t int f0/0 no shutdown ip add 192.168.1.1 255.255.255.0 no ip routing end R2 f0/0: conf t ...

  5. Ubuntu18.04可执行文件运行提示No such file or directory

    参考原文见 https://blog.csdn.net/sun927/article/details/46593129? 最近我也遇到一个类似问题,同一个工具在Ubuntu16.04里面运行是好的,但 ...

  6. 解除TCL电视系统禁止adb安装

    我的问题:tcl电视能使用adb连接成功,但使用adb install安装软件时,提示错误 解决问题如下: $adb shell,输入:1. $setprop persist.tcl.debug.in ...

  7. Struts+Hibernate+Spring面试题合集及答案(转)

    Struts+Hibernate+Spring面试题合集及答案 Struts+Hibernate+Spring 面试题合集 1 1. Hibernate部分 2 1.1. Hibernate工作原理 ...

  8. Jrebel 远程热部署[Idea]

    服务器端 客户端-idea remote module 在服务器端,Tomcat的webapps下新建项目文件夹,如: demo/WEB-INF/classes/[jrebel.xml]

  9. STM32中ARM系列编译工具链的编译宏选择(__CC_ARM、__ICCARM__、__GNUC__、__TASKING__)

    一 前言 stm32 f103中.关系到一个选择何种编译宏的问题.这里就梳理一下吧. 二 正文 1  在 core_cm3.h 文件中,有如下代码: #if defined ( __CC_ARM ) ...

  10. JVM探秘:jstack查看Java线程状态

    本系列笔记主要基于<深入理解Java虚拟机:JVM高级特性与最佳实践 第2版>,是这本书的读书笔记. jstack命令可以打印Java进程的各个线程堆栈跟踪信息,可以用来查看Java中各个 ...