必须要抄袭一下这个代码

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 nlines 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.

Example

Input
a8
h1
Output 

7
RD
RD
RD
RD
RD
RD
RD
   
大意:求最短路径的长度以及每一步的走法
某大神代码
 #include <iostream>
#include <cmath>
using namespace std;
int main()
{
char s1[],s2[];
while(cin>>s1>>s2)
{
int x=s2[]-s1[];//LR
int y=s2[]-s1[];//UD
cout<<max(abs(x),abs(y))<<endl;
while(x||y)
{
if(x>)
x--,cout<<"R";
if(x<)
x++,cout<<"L";
if(y>)
y--,cout<<"U";
if(y<)
y++,cout<<"D";
cout<<endl;
}
}
return ;
}
 

Shortest path of the king的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. A - Shortest path of the king (棋盘)

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

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

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

  6. 3A. Shortest path of the king

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

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

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

  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. ArcGIS 网络分析[1.4] 制作点线要素时需要注意的地方

    有很多同学虽然成功做好了网络数据集,但是分析时会出现这样的问题: 这是为什么呢? 这有三个可能的原因: 1. 两个点之间所有的道路没有连通(问题出在点.线数据上). 2. 网络数据集出现了孤立的点位置 ...

  2. HNOI2013 BZOJ3142 数列

    尝试用Markdown写一篇博客 3142: [Hnoi2013]数列 Description 小T最近在学着买股票,他得到内部消息:F公司的股票将会疯涨.股票每天的价格已知是正整数,并且由于客观上的 ...

  3. apache泛域名解析

    <VirtualHost *:80>    DocumentRoot "E:\work\phpStudy\WWW\ncpx\web"    ServerName ncp ...

  4. 关于js代码执行顺序

    上网查了一下关于这个方面的资料,大部分都是关于两个script标签中的js代码和变量以及函数提升方面的知识. 1.两个script标签 <script> alert("我是代码块 ...

  5. Python学习(四):模块入门

    1.模块介绍 模块:代码实现的某个功能的集合 模块分类: 自定义模块 内置标准模块 开源模块 模块的常用方法: 是否为主文件:__name__ == '__main__' 如果是直接执行的某程序,那么 ...

  6. ln 命令详解

    ln 命令 作用:它的功能是为某一个文件在另外一个位置建立一个同步的链接 参数:必要参数:  -b 删除,覆盖以前建立的链接  -d 允许超级用户制作目录的硬链接  -f 强制执行  -i 交互模式, ...

  7. 解决openssh漏洞,升级openssh版本

    关于解决漏洞的问题我就不详说了,主要就是升级版本.这里我们就直接简单记录下步骤: 1.升级 使用root用户登录系统进入到/home/guankong ,上传openssh-6.6p1.tar.gz到 ...

  8. tomcat部署项目时省略项目名

    大家也许知道在eclipse上通过新建server来部署项目到tomcat,并且通过server来管理项目的启动配置.server会自动创建启动该项目的xml 如: <Context docBa ...

  9. oracle 处理时间和金额大小写的相关函数集合

    CREATE OR REPLACE FUNCTION MONEY_TO_CHINESE(MONEY IN VARCHAR2) RETURN VARCHAR2 IS C_MONEY ); M_STRIN ...

  10. vmware workstation14永久激活密钥分享

    vmware workstation14永久激活密钥分享 VMware Workstation是一款功能强大的桌面虚拟计算机软件,简单来说就是最强的中文虚拟机了,可以在桌面上运行不同的操作系统,下面就 ...