【瞎搞】 UVALive 6527 Counting ones
来源:互联网 发布:mac怎么升级到os10.11 编辑:程序博客网 时间:2024/05/17 03:05
题目地址
例:
0000
0001
0010
0011
0100
0101
0110
0111
每一位上的个数都是 每 2^i的数 最后2^(i-1)都为 1
#include <cstdio>#include <cstring>#include <cstdlib>#include <string>#include <iostream>#include <algorithm>#include <sstream>#include <cmath>using namespace std;#include <queue>#include <stack>#include <vector>#include <deque>#define cler(arr, val) memset(arr, val, sizeof(arr))#define FOR(i,a,b) for(int i=a;i<=b;i++)#define IN freopen ("in.txt" , "r" , stdin);#define OUT freopen ("out.txt" , "w" , stdout);typedef long long LL;const int MAXN = 10052;const int MAXM = 6000010;const int INF = 0x3f3f3f3f;const int mod = 1e9;const double eps= 1e-8;#define lson l,m, rt<<1#define rson m+1,r,rt<<1|1int main(){#ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout);#endif LL a,b; while(cin>>a>>b) { a--; LL sum1=0,sum2=0; LL n=a; LL i=0; while(n) { i++; LL po=(LL)pow(2,i); LL po2=(LL)pow(2,i-1); LL moo=a%po; if(moo>=po/2) sum1+=a/po*po2+moo-(po2-1); else sum1+=a/po*po2; n/=2; } n=b; i=0; while(n) { i++; LL po=(LL)pow(2,i); LL po2=(LL)pow(2,i-1); LL moo=b%po; if(moo>=po/2) sum2+=b/po*po2+moo-(po2-1); else sum2+=b/po*po2; n/=2; } cout<<sum2-sum1<<endl; } return 0;}
0 0
- 【瞎搞】 UVALive 6527 Counting ones
- UVALive 6527 Counting ones
- UVALive 6527 Counting ones dfs(水
- Live Archive 6527 Counting ones
- Counting Ones
- 【瞎搞】 UVALive 6530 Football
- LA 6527 Counting ones 数位dp
- pat 1049 Counting Ones
- 1049. Counting Ones
- 1049. Counting Ones (30)
- PAT 1049 Counting Ones
- pat 1049 Counting Ones
- 1049. Counting Ones (30)
- 1049. Counting Ones (30)
- pat 1049 Counting ones
- 1049. Counting Ones (30)
- 1049. Counting Ones (30)
- 1049. Counting Ones
- bzoj 1702: [Usaco2007 Mar]Gold Balanced Lineup 平衡的队列
- eclipse 导入一个maven工程后 一直显示 importing maven projects 10%
- 【多线程】(三)经典多线程问题
- vmware 安装mac 10.9.3
- 数据结构栈和队列的括号匹配函数
- 【瞎搞】 UVALive 6527 Counting ones
- HDU 1058 Humble Numbers
- Kettle 体系架构
- jquey 常用按钮操作
- LeetCode 139 Roman to Integer
- 微信公众平台开发之模板消息(Java)
- 安装VMware Workstation8.0.3
- OpenGL小探3——纹理映射
- 【瞎搞】 UVALive 6530 Football