3A. Shortest path of the king
给你一个的棋盘,
#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的更多相关文章
- node搜索codeforces 3A - Shortest path of the king
发一下牢骚和主题无关: 搜索,最短路都可以 每日一道理 人生是洁白的画纸,我们每个人就是手握各色笔的画师:人生也是一条看不到尽头的长路,我们每个人则是人生道路的远足者:人生还像是一块神奇的土地 ...
- 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 ...
- 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 ...
- Shortest path of the king
必须要抄袭一下这个代码 The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose h ...
- 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 ...
- 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 ...
- Codeforces Beta Round #3 A. Shortest path of the king
标题效果: 鉴于国际棋盘两点,寻求同意的操作,是什么操作的最小数量,在操作过程中输出. 解题思路: 水题一个,见代码. 以下是代码: #include <set> #include < ...
- CF3A 【Shortest path of the king】
一句话题意:在8 * 8的棋盘上,输出用最少步数从起点走到终点的方案 数据很小,可以广搜无脑解决 定义数据结构体 struct pos{ int x,y,s; //x.y表示横纵坐标,s表示步数 ]; ...
- 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 ...
随机推荐
- Java基础知识强化之集合框架笔记31:集合之泛型类的概述和基本使用
1. 为什么会有泛型呢? (1)早期的Object类型可以接收任意的对象类型,但是在实际使用中,会有类型转换的问题,也存在这隐患,所以Java提供了泛型来解决这个安全问题. 2. 泛型类的使用: (1 ...
- titlebar和actionbar上的按钮设置
---恢复内容开始--- Actionbar加按钮: 在res文件夹下新建menu文件夹(如果你没有),然后添加一个XML文件 <?xml version="1.0" enc ...
- java之log4j的配置
java之log4j的配置 log4j有很多的优点,用起来很方便,就是配置起来有些麻烦,下面我介绍一下log4j的配置方法. log4j是用来记录日志的. 软件的运行过程离不开日志.日志主要用来记录系 ...
- jdbc mysql - Column count doesn't match value count at row 1.
该句的意思是,insert操作的SQL语句里列的数目和后面值的数目不一致.比如说, String sql = "insert into t_aqi(city_name, cur_date, ...
- ArcMap - 分割.
一,分割面: 1,在屏幕上新增线分割面: 使待编辑的面处于编辑状态 -> 选择待分割的面(使其处于选中状态) -> 选择编辑工具的 (Cut Polygons Tools) ->画线 ...
- 用sed、awk、grep同时匹配多个条件(与模式、或模式)
同时匹配ABC 和 123:sed -n '/ABC/{/123/p}' awk '/ABC/&&/123/{ print $0 }' grep -E '(ABC.*123|123.* ...
- 在万网虚拟主机上部署MVC5
参考 要想部署mvc,需要把一些mvc用到的全局程序集改为本地部署,通过N次试验,终于搞定. 特写个备忘录,免得以后忘了. 首先更改web.config,在里面加上 <system.web> ...
- VisualStudio2013&VS2015内置SQLServer入门 (三)
关于LocalDB的部署(publish): 使用本机做服务器(目测不可行) 双击项目的Properties-->Publish-->Application Files,你会发现没有.md ...
- 线程取消 (pthread_cancel)
线程取消(pthread_cancel) 基本概念pthread_cancel调用并不等待线程终止,它只提出请求.线程在取消请求(pthread_cancel)发出后会继续运行,直到到达某个取消点(C ...
- LA 6856 Circle of digits 解题报告
题目链接 先用后缀数组给串排好序.dc3 O(n) 二分答案+贪心check 答案的长度len=(n+k-1)/k 如果起点为i长为len串大于当前枚举的答案,i的长度取len-1 从起点判断k个串的 ...