Timus #1155

题目说明:立方体相邻两点可以同时相加或相减,要把每个点变为0的过程

解题思路:
1. 要有解则A + C + F + H = B + D + E + G
2. 进入循环直至每个点为0
3. 找到最小的位置。如果这个最小的位置旁边3个点都为0,则找到另外一个有数的点,再找这两点分别相邻的相邻的点加1。如果这个最小的位置旁边3个领点有数字,则找一个有数字的点进行相减。(听上去会有点绕)

  • Firstly, if it possible it will satisfy the equation A + C + F + H = B + D + E + G.
  • Secondly, go into loop, if every position is 0 quit the loop.
  • Thirdly, find the maximum position to decrease/increase. If this maximum position doesn’t have adjacent position to decrease, than find another position with value (not 0), increase 1 to two adjacent position adjacent to the maximum position and another position. Else decrease 1 to maximum position and the position adjacent to it.

发表评论

您的电子邮箱地址不会被公开。

浙ICP备2021019730-1    浙公网安备 33010902002953号
Copyright © 2022 PanCake