f*******l 发帖数: 66 | 1 A robot is initially in coordinate (0,0), and could move in four directions
(1,0) (0,1) (-1,0),(0,-1). It can not reach (x,y) where sum of digits(x,y)
larger than 28(or to generalize, k). For example, (279,89) 2+7+9+8+9 > 28, (
-279,89) the same.
Question: print out all the points the robot can reach.
| H***e 发帖数: 476 | 2 backtracking 吧
directions
(
【在 f*******l 的大作中提到】 : A robot is initially in coordinate (0,0), and could move in four directions : (1,0) (0,1) (-1,0),(0,-1). It can not reach (x,y) where sum of digits(x,y) : larger than 28(or to generalize, k). For example, (279,89) 2+7+9+8+9 > 28, ( : -279,89) the same. : Question: print out all the points the robot can reach. : :
| z******w 发帖数: 36 | 3 use DFS start from 0,0 to find all the points it can reach | c*****e 发帖数: 737 | 4 find:9006221 points.
1 #include
2 #include
3 #include | f*******l 发帖数: 66 | 5 Is there a boundary between reachable and unreachable? How is the shape look
like?
is it possible to use hash to replace
bool findCord(int x_, int y_)?
【在 c*****e 的大作中提到】 : find:9006221 points. : 1 #include : 2 #include : 3 #include
| p*****2 发帖数: 21240 | 6 这题就是数学题吧?4个方向都能走。就是看x和y的digits是不是sum大于k。
如果没有boundary的话,不是可以很大吗?
比如1000000000000........, 100000000000000....... | k****e 发帖数: 297 | 7 如果每次只能移一格的话,肯定是会碰到边界的。到不了很大
【在 p*****2 的大作中提到】 : 这题就是数学题吧?4个方向都能走。就是看x和y的digits是不是sum大于k。 : 如果没有boundary的话,不是可以很大吗? : 比如1000000000000........, 100000000000000.......
| p*****2 发帖数: 21240 | 8
明白了。一会儿想想。
【在 k****e 的大作中提到】 : 如果每次只能移一格的话,肯定是会碰到边界的。到不了很大
| c*****e 发帖数: 737 | 9 当然有边界的,不会走到无穷远的。
look
【在 f*******l 的大作中提到】 : Is there a boundary between reachable and unreachable? How is the shape look : like? : is it possible to use hash to replace : bool findCord(int x_, int y_)?
| C***U 发帖数: 2406 | 10 我觉得这办法不错哎
稍微修改一下BFS的code就可以了
【在 z******w 的大作中提到】 : use DFS start from 0,0 to find all the points it can reach
|
|