算法竞赛中 C++常用方便的函数

目录

_builtin_popcount()

_builtin_popcountll()

next_permutation(p,p+n)

lower_bound() ,up_bound()

assert(bool a);

二进制运算符:

64位最大数的边界

字符串函数:

priority_queue

unique


_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() ,upper_bound()

头文件: #include<algorithm>

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

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

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

 

assert(bool a);

头文件:#include <cass

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值