Welcome![Sign In][Sign Up]
Location:
Search - knight.r

Search list

[Windows Developknight

Description: 在一个n*n个方格的国际象棋棋盘上,马(骑士)从任意指定方格出发,按照横1 步竖2 步,或横2 步竖1步的跳马规则,走遍棋盘的每一个格子,且每个格子只走1次。这样的跳马步骤称为1 个成功的骑士征途。例如,当n=5 时的1 个成功的骑士征途如下图所示。 1 2 3 4 5 1 25 14 1 8 19 2 4 9 18 13 2 3 15 24 3 20 7 4 10 5 22 17 12 5 23 16 11 6 21 算法设计: 对于给定的n和n*n方格的起始位置x和y。用分支限界法找出从指定的方格(x,y)出发的一条成功的骑士征途。 数据输入: 第一行有1 个正整数n (1≤n≤10);第二行有2 个正整 数x 和y,表示骑士的起始位置为(x,y)。 结果输出: 如果不存在从(x,y)出发的成功的骑士征途则输出’No Solution!’。 输入: 5 1 3 输出 25 14 1 8 19 4 9 18 13 2 15 24 3 20 7 10 5 22 17 12 23 16 11 6 21-In an n* n squares on the chess board, horse (knight) starting from any given square, erected in accordance with step 1 step 2 horizontal, vertical or horizontal-step 1 step 2 vault rules, traveled to every board lattice, and each grid only take 1. This step is called a successful vault knights journey. For example, when n = 5 when a successful knight journey as shown below. 12345 125,141,819 24,918,132 315,243,207 4105221712 5231611621 Algorithm Design: For a given n and n* n grid starting position of the x and y. Using branch and bound method to find out from the specified grid (x, y) starting a successful journey Knight. Data entry: The first line has a positive integer n (1 ≤ n ≤ 10) the second line has two positive integers Number of x and y, said Cleveland s starting position (x, y). The resulting output: If not from the (x, y) the success of the Knights start the journey is the output No Solution! . Input: 5 13 Export 25,141,819 4918132
Platform: | Size: 881664 | Author: wakaka | Hits:

CodeBus www.codebus.net