from itertools import accumulate
from operator import add, xor, sub
def func(a: int, b: int) -> int:
return 1
if __name__ == "__main__":
# 1.itertools.accumulate学习
a = [1, 2, 3, 4, 5, 6]
print(list(accumulate(iterable=a))) # [1, 3, 6, 10, 15, 21]
print(list(accumulate(iterable=a, func=sub))) # [1, -1, -4, -8, -13, -19]
print(list(accumulate(iterable=a, func=add, initial=0))) # [0, 1, 3, 6, 10, 15, 21]
b = list(accumulate(iterable=a, func=add, initial=0))
print(b) # [0, 1, 3, 6, 10, 15, 21]
# 2. 对bit_count学习
print(b[5]) # 15
print(bin(b[5])) # 0b1111
print(b[5].bit_count()) # 4
accumulate 积累
from itertools import accumulate
from operator im