给你一个的棋盘,

问:从一个坐标到达另一个坐标需要多少步?
每次移动可以是八个方向。
 
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
using namespace std;
typedef long long LL;
const LL INF = 0xffffff;
const int maxn = ;
const LL MOD = 1e9+; void solve(int sx,int sy,int ex,int ey)
{
int x = ex - sx;
int y = ey - sy;
int n = min(abs(x), abs(y));
int step = max(abs(x), abs(y)) ;
printf("%d\n", step);
for(int i=; i<=n; i++)
{
if(x > && y > ) puts("RU");
if(x > && y < ) puts("RD");
if(x < && y > ) puts("LU");
if(x < && y < ) puts("LD");
}
n = max(abs(x), abs(y)) - n; for(int i=; i<=n; i++)
{
if( abs(x) > abs(y) && x > ) puts("R");
if( abs(x) > abs(y) && x < ) puts("L");
if( abs(y) > abs(x) && y > ) puts("U");
if( abs(y) > abs(x) && y < ) puts("D");
}
} int main()
{
char str[];
int sx, sy, ex, ey;
scanf("%s", str);
sx = str[] - 'a' + ;
sy = str[] - '';
scanf("%s", str);
ex = str[] - 'a' + ;
ey = str[] - '';
solve(sx, sy, ex, ey); return ;
}

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

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

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

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

  4. Shortest path of the king

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

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

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

  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. titlebar和actionbar上的按钮设置

    ---恢复内容开始--- Actionbar加按钮: 在res文件夹下新建menu文件夹(如果你没有),然后添加一个XML文件 <?xml version="1.0" enc ...

  2. PHP获取文件行数

    原文出处 提供两种实现方法,但是第一种效率最好 第一种: <?php $file_path = 'test.txt'; //文件路径 此处找一个1094644行的TXT文件 test.txt $ ...

  3. C## 输出Hello world

    首先新建一个项目 然后在文件D:\C##Obj\HelloWorld\HelloWorld\Program.cs using System; using System.Collections.Gene ...

  4. java web(jsp)-The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

    在静态项目上新建 jsp文件的时候,报错:The superclass "javax.servlet.http.HttpServlet" was not found on the ...

  5. 部分A+B_1

    正整数A的“DA(为1位整数)部分”定义为由A中所有DA组成的新整数PA.例如:给定A = 3862767,DA = 6,则A的“6部分”PA是66,因为A中有2个6. 现给定A.DA.B.DB,请编 ...

  6. cocos2d-x学习之类型转换(转)

    在做数据转换时,最好包含以下头文件 #include <iostream> #include <cmath> #include <string> #include  ...

  7. 英语学习[ZZ]

    本文作者三年间从四级勉强及格到高级口译笔试210,口试232.找工作面试时给其口试的老外考官听了一分钟就说你的英语不用考了.虽不敢说方法一定是最好的,但从现在开始随便谁不要再去找学习资料,每天花两个钟 ...

  8. SGU 135.Drawing Lines

    水题,不说了. #include <iostream> using namespace std; int f[70000]={1}; int n; int main(){ cin>& ...

  9. HTML5-黑客帝国2D

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

  10. JavaScript不可变原始值和可变的对象引用

    一.JavaScript不可变原始值 JavaScript中的原始值(undefined,null,布尔值,数字和字符串)与对象(包括了数组和函数)有着根本的区别.原始值是不可变的(undefined ...