Review of codeforces 484A Bits based on python

来源:互联网 发布:linux select 编辑:程序博客网 时间:2024/05/17 00:14

484A. Bits

This task is mainly about using ‘|’ (按位或), which can guanrantee the number of '1' to be maximum.

The source code is relatively easy.

n = input()for i in xrange(n):l, r = map(int, raw_input().split())while (l | (l + 1) <= r):l |= l + 1print l


0 0