给定两个整数:LR

∀ L ≤ A ≤ B ≤ R, 找出 A xor B 的最大值。

输入格式

第一行包含 L 第一行包含 R

数据范围

1 ≤ L ≤ R ≤ 103

输出格式

输出最大的异或和


题解:

 import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*; public class Solution {
/*
* Complete the function below.
*/ static int maxXor(int l, int r) {
int maxx = 0;
for(int i = l;i <= r;i++){
for(int j = l;j <= r;j++){
if(i != j)
maxx = Math.max(maxx,i^j);
}
}
return maxx; } public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int res;
int _l;
_l = Integer.parseInt(in.nextLine()); int _r;
_r = Integer.parseInt(in.nextLine()); res = maxXor(_l, _r);
System.out.println(res); }
}

最新文章

  1. GamePinTu
  2. [Linux] - CentOS中文乱码解决办法
  3. SQL Server Code tips (持续更新)
  4. ffmpeg常用命令
  5. C++pair类型
  6. Scrum会议2(Beta版本)
  7. 图解SSL/TLS协议
  8. 在Linux上安装JDK7
  9. MFC应用程序的开发流程
  10. pair work-Elevator Schedule
  11. Permutations,Permutations II,Combinations
  12. MFC网页访问的实现示例
  13. PAT (Advanced Level) 1113. Integer Set Partition (25)
  14. md编辑器测试
  15. 【SSH系列】深入浅出SpringMvc+入门Demo
  16. vue axios 封装(二)
  17. Android组件化demo实现以及遇坑分享
  18. P2331 [SCOI2005]最大子矩阵 (动规:分类讨论状态)
  19. js函数定义和调用
  20. Delphi获取公网IP地址函数

热门文章

  1. UVA1658 Admiral 拆点法解决结点容量(路径不能有公共点,容量为1的时候) 最小费用最大流
  2. atom安装插件
  3. Java进阶02 异常处理(转载)
  4. Eclipse 任务管理
  5. SQL Server 阻止了对组件“Ad Hoc Distributed Queries”的 STATEMENT“OpenRowset/OpenDatasource”的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 sp_configure 启用“Ad Hoc Distributed Queries”。有关启用“Ad Hoc Distributed Queries”
  6. 不通过AppStore,在iOS设备上直接安装应用程序的原理
  7. IIPP迷你项目(三)“Stopwatch: The Game”
  8. EasyNVR现场部署搭配EasyNVS云端集中控制应用于幼儿园直播场景的最佳方案!
  9. HUST 1354 - Rubiks (DP)
  10. virsh命令行管理工具