早教吧 育儿知识 作业答案 考试题库 百科 知识分享

Wehaveanarrayofpositiveintegers.Wewilltransformthisarraybyrepeatingthefollowingoperationuntiltherearelessthantwoelementsleft:Choosethetwoelementsthathavetheminimalabsolutedifference.Iftherearemultiplesuchpairs,cho

题目详情
We have an array of positive integers.We will transform this array by repeating the following operation until there are less than two elements left:
Choose the two elements that have the minimal absolute difference.If there are multiple such pairs,choose the one among them with the minimal sum.If there are still multiple pairs,choose any one of them.
Decrease both elements in the pair by 1.
Remove all zeros from the array.
It's easy to see that this process always ends in a finite number of steps.
▼优质解答
答案和解析
array可以是排列,阵容,级数,数组.由于不知道你这段话出自哪个领域,姑且译成“序列”.
现有一正整数序列,对该序列重复下列操作,直到剩余的数的个数少于两个:
选择具有最小的绝对差的两个数,如果有多组这样的数,选择其中和最小的一组.如果仍有多组,选择其中任何一组,
将这两个数各减去1,
去掉序列中所有的0.
容易看出,上述操作总是包含有限个步骤.