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. 验证试验 更改了从机CAN通信的MAC地址 从机新挂CAN网络 上电自检通过

    更改前 该之后 主机程序 与 从机 程序 已经上传到网盘上 ,主机和从机程序基本一致, 唯一的区别是 从机更好了MAC地址 为0X10  主机的固定MAC地址为 0X1F 改程序的配置上设置的是双滤波 ...

  2. 【LeetCode】不同二叉搜索树

    [问题] 卡特兰(Catalan)数来源于卡特兰解决凸n+2边形的剖分时得到的数列Cn,在数学竞赛.信息学竞赛.组合数学.计算机编程等方面都会有其不同侧面的介绍.卡特兰问题的解决过程应用了大量的映射方 ...

  3. Python 中 unittest 框架加载测试用例的常用方法

    unittest 当中为我们提供了许多加载用例的方法,这里说下常用的两种方法...推荐使用第二种 第一种加载测试用例的方法:使用加载器加载两个模块 需要把所有的模块加载到套件中 那么就可以自动的运行所 ...

  4. 九十五、SAP中查看自定义包的所有模块,对象,函数主,事务等

    一.输入SE80 二.选择包,再查下Z* 三.可以看到,查下出来的包 四.可以看到我们想要的内容了

  5. 十二、JavaScript之变量申明

    一.代码如下 二.运行效果如下 <!DOCTYPE html> <html> <meta http-equiv="Content-Type" cont ...

  6. 082-PHP的do-while循环break跳出

    <?php $i = 1; do { echo $i; $i = $i + 1; if ($i >= 5) { echo "break<br>"; brea ...

  7. 8. Redis 持久化对生产环境的灾难恢复的意义

    1.故障发生的时候会怎么样2.如何应对故障的发生 很多同学,自己也看过一些redis的资料和书籍,当然可能也看过一些redis视频课程 所有的资料,其实都会讲解redis持久化,但是有个问题,我到目前 ...

  8. Flink Window窗口机制

    总览 Window 是flink处理无限流的核心,Windows将流拆分为有限大小的"桶",我们可以在其上应用计算. Flink 认为 Batch 是 Streaming 的一个特 ...

  9. [CSS]水平垂直居中方案

    简单总结一下常用的水平垂直居中方案 直接在父级元素设置 text-align 和 line-height ,针对未浮动的行内元素 <div class="box"> & ...

  10. 吴裕雄 Bootstrap 前端框架开发——Bootstrap 字体图标(Glyphicons):glyphicon glyphicon-share

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...