找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 2400|回复: 6
收起左侧

[面经题目讨论] Monkey Grid 问题边界值的问题

[复制链接]

49

主题

1

精华

449

积分

高级会员

Rank: 3Rank: 3

积分
449
发表于 9-3-2015 12:54 PM | 显示全部楼层 |阅读模式

亲!马上注册或者登录会查看更多内容!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
                               
题目是这样子的:
Thereis a monkey which can walk around on a planar grid. The monkey canmove one space at a time left, right, up or down. That is, from (x,y) the monkey can go to (x+1, y), (x-1, y), (x, y+1), and (x, y-1).Points where the sum of the digits of the absolute value of the xcoordinate plus the sum of the digits of the absolute value of the ycoordinate are lesser than or equal to 19 are accessible to themonkey. For example, the point (59, 79) is inaccessible because 5 + 9+ 7 + 9 = 30, which is greater than 19. Another example: the point(-5, -7) is accessible because abs(-5) + abs(-7) = 5 + 7 = 12, whichis less than 19. How many points can the monkey access if it startsat (0, 0), including (0, 0) itself? There is no input for thisprogram.
Printout the how many points can the monkey access. (The number should beprinted as an integer whole number eg. if the answer is 10 (its not!!), print out 10, not 10.0 or 10.00 etc)
比方说,K=25,单个下标的最大值是898,这个值是怎么算出来的,如何证明?

7 k: F# W% `; @; D" f5 S; i) a/ Y2 ~  a$ x4 I% H0 c$ _0 \- Y# n
发表于 9-4-2015 05:40 PM | 显示全部楼层
K是啥。。。另外我觉得这个就是BFS……

1

主题

1

精华

70

积分

资深会员

Rank: 2

积分
70
发表于 9-4-2015 11:49 PM | 显示全部楼层
感觉也是BFS+backtracking就好了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表