【codeforces 165E】 - Compatible Numbers 【位运算】

该博客探讨了在编程竞赛中遇到的E. Compatible Numbers问题,主要涉及位运算的概念。题目要求找出数组中每对元素是否能使得它们的按位与结果为0,即两数兼容。对于每个输入的数组元素,需要判断是否存在另一个元素与其兼容,并给出这样的配对。博客提供了一些样例测试用例和解决方案,包括使用DP预处理方法来解决这个问题。
摘要由CSDN通过智能技术生成

E. Compatible Numbers
time limit per test4 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
Two integers x and y are compatible, if the result of their bitwise “AND” equals zero, that is, a & b = 0. For example, numbers 90 (10110102) and 36 (1001002) are compatible, as 10110102 & 1001002 = 02, and numbers 3 (112) and 6 (1102) are not compatible, as 112 & 1102 = 102.

You are given an array of integers a1, a2, …, an. Your task is to find the following for each array element: is this element compatible with some other element from the given array? If the answer to this question is positive, then you also should find any suitable element.

Input
The first line contains an integer n (1 ≤ n ≤ 106) — the number of elements in the given array. The second line contains n space-separated integers a1, a2, …, an (1 ≤ ai ≤ 4·106) — the elements of the given array. The numbers in t

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值