题目1113:二叉树
来源:互联网 发布:信贷软件 编辑:程序博客网 时间:2024/05/01 07:14
import java.io.IOException;import java.io.FileReader;import java.util.Scanner;class Main{public static final boolean DEBUG = false;public static void main(String[] args) throws IOException{Scanner cin;int m, n;if (DEBUG) {cin = new Scanner(new FileReader("d:\\OJ\\uva_in.txt"));} else {cin = new Scanner(System.in);}while (cin.hasNext()) {m = cin.nextInt();n = cin.nextInt();if (m == 0 && n == 0) break;int depth1 = (int)(Math.log(m) / Math.log(2)) + 1;int depth2 = (int)(Math.log(n) / Math.log(2)) + 1;int sum = 0, k = 1;for (int i = 0; i < depth2 - depth1; i++) {sum += k;k *= 2;}int start = m * k, end = start + k;if (end <= n) sum += k;else {for (int i = start; i <= n; i++) sum++;}System.out.println(sum);}}}
0 0
- 题目1113:二叉树
- 题目1113:二叉树
- 题目1113:二叉树
- 题目1113:二叉树
- 题目1113:二叉树
- 题目1113:二叉树
- 题目1113:二叉树
- 题目1113:二叉树
- (题目33)题目1113:二叉树
- 33-题目1113:二叉树
- 九度OnlineJudge题目1113:二叉树
- 九度 题目1113:二叉树
- 九度Oj题目1113:二叉树
- 九度OJ题目1113:二叉树
- 题目1113:二叉树 九度OJ
- 题目1113:二叉树(二叉树结点问题)
- 二叉树相关题目
- 题目33:二叉树
- CEF:给客户端内嵌一个Chrome吧
- 软件工程(软件维护)
- miui 系统组件 功能提示
- 搭建企业级单元测试环境-Spring集成JUnit4/TestNG
- JAVA中的类,抽象类及接口
- 题目1113:二叉树
- 停止JQuery Ajax请求
- Cocos2dx 3.0 过渡篇(五) 随机数的获取
- 用TP做贴脸熄屏的方法
- Asp.net 一般处理程序+扩展
- 规避触摸屏模拟距离传感器失效的问题
- 内部类的创建与使用--java
- Android 中的WebView
- 用触摸屏来实现距离传感器的功能