A sequence a1,a2,…,ana1,a2,…,an is called good if, for each element aiai, there exists an element ajaj (i≠ji≠j) such that ai+ajai+aj is a power of two (that is, 2d2d for some non-negative integer dd).
For example, the following sequences are good:
- [5,3,11][5,3,11] (for example, for a1=5a1=5 we can choose a2=3a2=3. Note that their sum is a power of two. Similarly, such an element can be found for a2a2 and a3a3),
- [1,1,1,1023][1,1,1,1023],
- [7,39,89,25,89][7,39,89,25,89],
- [][].
Note that, by definition, an empty sequence (with a length of 00) is good.
For example, the following sequences are not good:
- [16][16] (for a1=16a1=16, it is impossible to find another element ajaj such that their sum is a power of two),
- [4,16][4,16] (for a1=4a1=4, it is impossible to find another element ajaj such that their sum is a power of two),
- [1,3,2,8,8
C - Summarize to the Power of Two 解题报告
最新推荐文章于 2021-04-11 15:27:07 发布
这是一个关于计算机科学中的算法问题,目标是确定为了使给定序列变成一个“好序列”(序列中任意元素都能与其他元素相加得到一个2的幂次)所需的最少元素删除数。通过预处理2的幂次并在输入序列中查找匹配项来解决此问题,同时考虑重复元素的情况。
摘要由CSDN通过智能技术生成