题目
题目描述
MianKing has nn piles of stones and each pile has at most 3 stones, now he wants to merge all of these stones into one pile.
In order to achieve his goal, each time MianKing can choose two piles of stones and merge them into a new pile, and the number of stones in the new pile is the sum of these two piles.
Because it takes manpower to move stones, in each operation if the numbers of these two piles of stones are xx and yy respectively, MianKing should pay(x mod 3)(y mod 3)(x~mod~3)(y~mod~3)(x mod 3)(y mod 3)coins for it.
Now MianKing wants to know the minimum amount of coins he need to pay to merge all of these stones into one pile.

题意
这题题意比较绕,一上来还读错了。。
给你a1a_1

博客围绕石头堆合并问题展开,给定不同石头数量的石堆,每次合并两堆费用为(x%3)*(y%3),目标是最小化将所有石堆合并成一堆的费用。思路是忽略三个一堆的石堆,优先合并1和2,处理剩余石堆,最后给出解题思路但未展示完整代码。
最低0.47元/天 解锁文章
3995

被折叠的 条评论
为什么被折叠?



