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.

Timus #1296

题目解释:最大子序列的和

说明

该板块为个人写过的 Timus 题目
该板块都为原创代码,搬运请注明出处,谢谢。
Github上别人写的代码您也可以作为 参考1 参考2

共性问题说明:
cin读取速度慢,但所有题目时间都考虑到cin时间,如果超时,建议换算法,实在不行可以加入:std::ios::sync_with_stdio(false);std::cin.tie(nullptr); 加快cin速度或者改成scanf或scanf_s(最快)。当scanf或scanf_s读入string后不要轻易改变该string赋值否则可能会有很大bug,建议用scanf输入时储存为char。并且建议不要混用cin和scanf。如果你追求极致时间,请用scanf和printf输入和输出。

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