- 博客(2)
- 资源 (1)
- 收藏
- 关注
原创 【hdu5747】Aaronson——popcount
题目: 题目链接描述:问一个数n可以被2的1到m次方表示的最小代价,使用一次2^k就带来1的代价。 n、m的范围都是1e9。题解:使用__builtin_popcount函数统计n中有多少个1(二进制),可以知道m不超过30。由于超过m的部分没法一次表示,所以减去,再加上n / 2^m即可。代码:#include <cstdio> #include <cstring> #include <cmat
2016-07-26 16:29:55 594
原创 【hdu3038】
题目:描述:题解:代码:#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 2e5 + 5; int fa[maxn], sum[maxn]; int find(int x) { if(fa[x] == -1) return x; int tmp
2016-07-19 10:22:10 817
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人