HBC216212JokewithpermutationNo114514题解

八贝勒 算法基础篇 40 0
挑战自我,勇攀编程高峰!全网最全C++题库,助您成为编程达人。
AweiAwei{}Awei found too much "114514114514{}114514" in this problem set. As a 2424{}24 years old student, he can't stand it anymore. So he invites you to help him clean up the problem set.

AweiAwei{}Awei found too much "114514114514{}114514" in this problem set. As a 2424{}24 years old student, he can't stand it anymore. So he invites you to help him clean up the problem set.                        AweiAwei{}Awei has a sequence AA{}A consists of NN{}N numbers, the indices label from 11{}1 to NN{}N. Each number AiA_iAi​ in the sequence can only be 11{}1 or 44{}4 or 55{}5. He does not want six consecutive numbers [1,1,4,5,1,4][1,1,4,5,1,4]{}[1,1,4,5,1,4] in the sequence AA{}A, so he invites you to perform some operations on the sequence. In one operation, you can select an integer ii{}i and change AiA_iAi​ to BiB_iBi​, BiB_iBi​ can only be 11{}1 or 44{}4 or 55{}5. Your task is to make the sequence AA{}A do not contains the six consecutive numbers [1,1,4,5,1,4][1,1,4,5,1,4]{}[1,1,4,5,1,4] in at most ⌊N6⌋lfloor frac {N}{6}rfloor⌊6N​⌋ (rounding down) operations. You are not required to minimize the number of operations.

HBC216212JokewithpermutationNo114514题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
全网最全C++题库,助您挑战自我,突破极限,成为编程领域的佼佼者!

标签: HBC216212JokewithpermutationNo114514题解