1680. Concatenation of Consecutive Binary Numbers
Содержание
class Solution:
def concatenatedBinary(self, n: int) -> int:
mod = 10**9 + 7
res = shift = 0
for i in range(1, n + 1):
if (i & (i - 1)) == 0:
shift += 1
res = (res << shift | i) % mod
return res