编程介的小学生 2017-09-04 09:42 采纳率: 20.5%
浏览 925
已采纳

Collecting Stones

Trudy is playing a phone game called Collecting Stones. In this game, a robert is placed on the upper-left corner of the board, which consists of 8x8 grids. On each grid, there are less than 2000001 stones. The robert can move up, down, right, up-right and down-right, but can not move into a grid that has already been passed before. All the stones on the grids which were passed by the robert are collected and Trudy is want to know if it is possible to collect exactly M number of stones when the robert arrives at the lower-right corner.

Input:

The first line of input contains a single integer T(T<=20), the number of testcases. In the first line of each testcase, there is a number M described above, and follows 8x8 numbers, which represents the number of stones on each grid. Note that M will not greater than the sum of all stones on the board.

Output:

For each testcase, output "Yes" if there exists a path for the robert to collect exactly M number of stones, output "No" otherwise.

Sample Input:
2
374
1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48
49 50 51 52 53 54 55 56
57 58 59 60 61 62 63 64
2032
1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48
49 50 51 52 53 54 55 56
57 58 59 60 61 62 63 64
Sample Output:
Yes
No
Note for the first sample: A possible path is 1, 10 18, 19, 20, 29, 38, 31, 40, 48, 56, 64.

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-09-18 02:42
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题