「算法竞赛进阶指南」0x01 位运算 知识笔记

二进制是计算机的根本!

你了解它吗?

int lowbit(int x)
{
	return x&(-x);//x&(~x+1),~x=-1-x;
}
int __builtin_ctz(unsigned int x)
int __builtin_ctzll(unsigned long long x)
返回x的二进制表示下最低位的1后面有多少个0 
int __builtin_popcount(unsigned int x)
int __builtin_popcountll(unsigned long long x)
返回x的二进制表示下有多少位为1 
posted @ 2018-12-17 20:14  h^ovny  阅读(173)  评论(0)    收藏  举报