搜索专题 题解

第一题 排列2

题解:https://blog.csdn.net/weixin_43731933/article/details/86826518

第二题 Counting Sheep

题解:https://blog.csdn.net/weixin_43731933/article/details/86825605

第三题 Square

题解:https://blog.csdn.net/weixin_43731933/article/details/86822057

第四题 Sum It Up

题解:https://blog.csdn.net/weixin_43731933/article/details/87023194

第五题 变形课

题解:https://blog.csdn.net/weixin_43731933/article/details/86803273

第六题 Substrings

题解:https://blog.csdn.net/weixin_43731933/article/details/86894975          (第八题)

第七题 Calling Extraterrestrial Intelligence Again

题解:https://blog.csdn.net/weixin_43731933/article/details/86826803

第八题 N皇后问题

题解:https://blog.csdn.net/weixin_43731933/article/details/86821773

第九题 Prime Ring Problem

题解:https://blog.csdn.net/weixin_43731933/article/details/86827100

第十题 Red and Black

题解:https://blog.csdn.net/weixin_43731933/article/details/86820580

第十一题 Oil Deposits

题解:https://blog.csdn.net/weixin_43731933/article/details/87214365

第十二题 Tempter of the Bone

题解:https://blog.csdn.net/weixin_43731933/article/details/86837242

第十三题 Asteroids!

题解:https://blog.csdn.net/weixin_43731933/article/details/87094286

第十四题 Fire Net

题解:https://blog.csdn.net/weixin_43731933/article/details/87211280

第十五题:寒冰王座

题解:https://blog.csdn.net/weixin_43731933/article/details/86820326

第十六题:胜利大逃亡

题解:https://blog.csdn.net/weixin_43731933/article/details/87094530

第十七题:Rescue

题解:https://blog.csdn.net/weixin_43731933/article/details/87212216

第十八题:Knight Moves

题解:https://blog.csdn.net/weixin_43731933/article/details/87210530

第十九题:A strange lift

题解:https://blog.csdn.net/weixin_43731933/article/details/86848449

第二十题:Safecracker

题解:https://blog.csdn.net/weixin_43731933/article/details/87095358

 

发布了199 篇原创文章 · 获赞 256 · 访问量 5万+
展开阅读全文

Knight Moves 骑士的移动问题

10-15

Description A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of n squares on a chessboard exactly once. He thinks that the most difficult part of the problem is determining the smallest number of knight moves between two given squares and that, once you have accomplished this, finding the tour would be easy. Of course you know that it is vice versa. So you offer him to write a program that solves the "difficult" part. Your job is to write a program that takes two squares a and b as input and then determines the number of knight moves on a shortest route from a to b. Input The input file will contain one or more test cases. Each test case consists of one line containing two squares separated by one space. A square is a string consisting of a letter (a-h) representing the column and a digit (1-8) representing the row on the chessboard. Output For each test case, print one line saying "To get from xx to yy takes n knight moves.". Sample Input e2 e4 a1 b2 b2 c3 a1 h8 a1 h7 h8 a1 b1 c3 f6 f6 Sample Output To get from e2 to e4 takes 2 knight moves. To get from a1 to b2 takes 4 knight moves. To get from b2 to c3 takes 2 knight moves. To get from a1 to h8 takes 6 knight moves. To get from a1 to h7 takes 5 knight moves. To get from h8 to a1 takes 6 knight moves. To get from b1 to c3 takes 1 knight moves. To get from f6 to f6 takes 0 knight moves. 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 技术黑板 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览