需要紧急注意......请告诉逻辑找到解决方案 [英] Urgent attention required...Please tell the logic to find the solution

查看:90
本文介绍了需要紧急注意......请告诉逻辑找到解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1,0

1,9

1,3

9,0

9,1

9,3

9,5

3,0

3,9

5,0



说明:逗号之前的数字(,)可以用逗号后的数字。

也就是说,1可以去到0,9和3.

3可以到0,9等等。

这个挑战的主要动机是从一个数字移动到另一个数字最短的移动。



输入:1,5

输出:3

1 - > 9 - > 5

1,0
1,9
1,3
9,0
9,1
9,3
9,5
3,0
3,9
5,0

Explanation : digit before comma(,) can go to digit after comma.
That is, 1 can go to 0,9, and 3.
3 can go to 0,9 and so on.
The main motive of this challenge is to move from one digit to another in shortest possible moves.

Input : 1,5
Output : 3
1-->9-->5

推荐答案

这类似于众所周知的旅行推销员问题 [ ^ ]。如果你的实际输入很短,那么即使是暴力攻击也是合适的。
This resembles the well known "traveling salesman problem"[^]. If your actual input is going to be so short then even a 'brute-force-attack' is suitable.


这篇关于需要紧急注意......请告诉逻辑找到解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆