洛谷2431 正妹吃月饼
来源:互联网 发布:甲骨文java认证 编辑:程序博客网 时间:2024/06/09 13:39
题目:http://www.luogu.org/problem/show?pid=2431
分析:a是保底解,那么就暴力枚举能否加上一个使得a+(1<< i)<=b
代码:
#include <cstdio>#include <algorithm>using namespace std;const long long int ONE=1;const int Tmax=70;long long int x,y,tmpx;int a[Tmax],lena=-1,ans;void init(){ tmpx=x; while(tmpx>0) { a[++lena]=tmpx&1; tmpx>>=1; } return;}void work(){ int i; for(i=0;i<=62;i++) { if(a[i]==1) ans++; else { x+=(ONE<<(i)); if(y>=x) ans++; } } printf("%d",ans); return;}int main(){ scanf("%lld%lld",&x,&y); if(x>y) { printf("0"); return 0; } init(); work(); return 0;}
1 0
- 洛谷2431 正妹吃月饼
- 洛谷 P2431 正妹吃月饼
- 【数论】[luoguP2431]正妹吃月饼
- 月饼
- 月饼
- 月饼
- 月饼机小介
- PAT1020. 月饼
- pat_b_1020 月饼
- 1020. 月饼
- 1020月饼
- 1020. 月饼
- 1020. 月饼
- PAT1020月饼
- pat1020:月饼
- 1020. 月饼
- PAT 月饼
- 1020 月饼
- vs2013中opencv的配置
- chi-square test或称卡方检验
- Java 开源博客 Solo 1.1.0 发布 - 告别 GAE
- 基准点压芯片锦
- c++ primer 练习5.14
- 洛谷2431 正妹吃月饼
- 关于安全的一点思考
- 常用运算电压比较器目录
- 输入三个数求由小到大顺序的另一种写法
- 进程和线程
- Java 实时论坛 - Sym 1.3.0 发布
- Linux系统的头文件和库文件搜索路径
- Android AsyncTask类的使用(二),加载ListView的Item的图片
- 洛谷2448 无尽的生命