目录

_builtin_popcount()

_builtin_popcountll()

next_permutation(p,p+n)

lower_bound() ,up_bound()

assert(bool a);

二进制运算符:

64位最大数的边界

字符串函数:

【c++】STL里的priority_queue用法总结



_builtin_popcount()

计算32位二进制中多少个1

_builtin_popcountll()

计算64位二进制中多少个1

long long 写法看自codeforces  放回一个int值

 

next_permutation(p,p+n)

while(next_permutation(p,p+n)){
      进行某种操作
}

全排列函数 数组p  一共有n个元素

 

lower_bound() ,up_bound()

头文件: #include<algorithm>

lower_bound(first, last, val) 返回非递减序列【first, last】中第一个大于等于val的数的位置         

 用于LCS    eg:得出的值减去起点的位置就可以得出是第几个数

up_bound()返回非递减序列【first, last】中第一个大于val的数的位置

 

assert(bool a);

头文件:#include <cassert>

如果a == false, 终止程序运行。

二进制运算符:

按位与运算符(&):1&1=1    1&0=0  0&1=0   0&0=0

按位或运算符(|):  1|1=1     1|0=1    0|1=1    0|0=0

异或运算符(^):1^1=0    0^1=1   1^0=1    0^0=0

1、交换律

2、结合律(即(a^b)^c == a^(b^c))

3、对于任何数x,都有x^x=0,x^0=x

4、自反性:  a^b^b=a^0=a;

<< : 左移运算符,num << 1,相当于num乘以2

>> :  右移运算符,num >> 1,相当于num除以2

 

64位最大数的边界

usigned long long lim = ~0LL >> 1;

usigned 无符号

printf(“%llu”,lim);

 

字符串函数:

C语言写法:

strcpy     strncpy   

stcat 

strchr    strrchr 

strcmp   

strlen 

strspn    strcspn

strerror

strtok

strstr  strpbrk

atoi

 详细解释:   传送门

【c++】STL里的priority_queue用法总结

传送门