LightOJ 1042 - Secret Origins
来源:互联网 发布:js获取元素的高度 编辑:程序博客网 时间:2024/04/30 19:41
http://www.lightoj.com/volume_showproblem.php?problem=1042
代码:
#include<cstdio>#include<cstring>#include<iostream>#include<cmath>#include<string>#include<vector>#include<map>using namespace std;int Rint() { int x; scanf("%d", &x); return x; }#define FOR(i, a, b) for(int i=(a); i<(b); i++)#define REP(x) for(int i=0; i<(x); i++)#define int64 long long#define INF 1<<30#define bug(s) cout<<#s<<"="<<s//低位的一个01组合,变为10. 更低位的1全移到最末int BitCount(unsigned int n) { n = (n & 0x55555555) + ((n >> 1) & 0x55555555) ; n = (n & 0x33333333) + ((n >> 2) & 0x33333333) ; n = (n & 0x0f0f0f0f) + ((n >> 4) & 0x0f0f0f0f) ; n = (n & 0x00ff00ff) + ((n >> 8) & 0x00ff00ff) ; n = (n & 0x0000ffff) + ((n >> 16) & 0x0000ffff) ; return n ; } int solve(int x){int lowbit = x&(-x);int y = (-x)^lowbit;int lowzero = y&(-y);int ans = (x|lowzero)^(lowzero>>1);int cnt = BitCount((unsigned int)(ans&(lowzero-1)));ans = (ans|(lowzero-1))^(lowzero-1);ans|=(1<<cnt)-1;return ans;}int main(){int T = Rint();for(int t=0; t<T; t++){printf("Case %d: %d\n", t+1, solve(Rint()));}}
- LightOJ 1042 - Secret Origins
- LightOJ 1042 Secret Origins
- lightoj 1042 - Secret Origins
- lightoj 1042 - Secret Origins 【数学】
- LightOJ 1042 Secret Origins 贪心
- LightOJ 1042 Secret Origins(二进制、STL)
- LightOJ - 1042 Secret Origins (模拟)水
- LightOJ 1042 Secret Origins【位运算】
- LightOJ 1042 Secret Origins(贪心)
- LightOJ-1042---Secret Origins (贪心+暴力)
- lightoj 1042 Secret Origins(位运算符号的应用)
- LightOJ 1042 - Secret Origins(数论&进制转换)
- 1042 - Secret Origins
- light oj 1042 Secret Origins
- Secret Origins
- 1042 - Secret Origins (位运算好题)
- LightOJ1042 - Secret Origins (位运算)
- <LightOJ 1338> Hidden Secret!
- Intent有关的作用用法
- 优先队列 懒省事的小明
- 布局总结,还不错的一篇总结较全
- 必看的应用有很大帮助
- ipad2 越狱后安装slide enhancer 隐藏滑块解决方法总结
- LightOJ 1042 - Secret Origins
- 语言文件 po 和 mo 的互相转换
- lisp函数(二)apply/mapcar
- Oracle 11G XE 安装笔记(新手向)
- lisp 函数(三)
- erlang 中文手册——list
- 黑马程序员____程序设计语言Java
- 一个简单的游戏服务器框架
- 信息安全专业