位运算模版 Ian 2023-02-01 约 91 字 预计阅读 1 分钟 次阅读 目录 遍历子集 1 2 3 4 y = st # 生成 st 的所有子集 while y: # 处理子集 y y = (y-1)&st Gosper’s Hack 算法学习笔记(75): Gosper’s Hack 1 2 3 4 5 6 7 8 st,ma = (1<<k)-1, 1<<n # 生成 n 元集合所有 k 元子集 while st<ma: # 处理子集 st lb = st&-st r = st+lb st = (r^st)>>(lb.bit_length()+1)|r if st==0: break 提交0 评论加载更多...Powered By Valinev1.4.14 Please enable JavaScript to view the comments powered by Valine.
v1.4.14