//http://codeforces.com/contest/631/problem/A
package codeforces344; import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer; /**
* Created by lenovo on 2016-03-10.
*/
public class A344 {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof; void solve() throws IOException {
int n = nextInt();
int[] a = new int[1000 + 10];
int[] b = new int[1000 + 10];
for(int i = 0; i < n; ++i) {
a[i] = nextInt();
}
for(int i = 0; i < n; ++i) {
b[i] = nextInt();
} long max = -1;
for(int i = 0; i < n; ++i) {
for(int j = 0; j < n; ++j){
max = Math.max(max, f(a, b, i, j));
}
}
System.out.println(max);
} long f(int[] a, int[] b, int i, int j) {
int va = a[i];
int vb = b[i];
for(int ii = i; ii <= j; ++ii){
va = va | a[ii];
vb = vb | b[ii];
}
//System.out.println("va + vb " + va + vb);
return va + vb;
} A344() throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
solve();
out.close();
br.close();
}
public static void main(String[] args) throws IOException{
new A344();
}
String nextToken(){
while(st == null || !st.hasMoreTokens()){
try{
st = new StringTokenizer(br.readLine());
} catch(IOException e) {
eof = true;
return null;
}
}
return st.nextToken();
} String nextString(){
try{
return br.readLine();
} catch (Exception e) {
eof = true;
return null;
}
} int nextInt() throws IOException {
return Integer.parseInt(nextToken());
} long nextLong() throws IOException {
return Long.parseLong(nextToken());
} double nextDouble() throws IOException {
return Double.parseDouble(nextToken());
}
}

  

水题异常的好刷 T_T

Codeforces Round #344 (Div. 2) A. Interview的更多相关文章

  1. Codeforces Round #344 (Div. 2) A. Interview 水题

    A. Interview 题目连接: http://www.codeforces.com/contest/631/problem/A Description Blake is a CEO of a l ...

  2. Codeforces Round #344 (Div. 2) A

    A. Interview time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  3. Codeforces Round #344 (Div. 2)(按位或运算)

    Blake is a CEO of a large company called "Blake Technologies". He loves his company very m ...

  4. Codeforces Round #344 (Div. 2)

    水 A - Interview 注意是或不是异或 #include <bits/stdc++.h> int a[1005], b[1005]; int main() { int n; sc ...

  5. Codeforces Round #344 (Div. 2) E. Product Sum 维护凸壳

    E. Product Sum 题目连接: http://www.codeforces.com/contest/631/problem/E Description Blake is the boss o ...

  6. Codeforces Round #344 (Div. 2) D. Messenger kmp

    D. Messenger 题目连接: http://www.codeforces.com/contest/631/problem/D Description Each employee of the ...

  7. Codeforces Round #344 (Div. 2) C. Report 其他

    C. Report 题目连接: http://www.codeforces.com/contest/631/problem/C Description Each month Blake gets th ...

  8. Codeforces Round #344 (Div. 2) B. Print Check 水题

    B. Print Check 题目连接: http://www.codeforces.com/contest/631/problem/B Description Kris works in a lar ...

  9. Codeforces Round #344 (Div. 2) B. Print Check

    B. Print Check time limit per test 1 second memory limit per test 256 megabytes input standard input ...

随机推荐

  1. file xxx from install of xxx conflicts with file from xxx

    执行安装 rpm -ivh lib64stdc++6-4.6.1-2-mdv2011.0.x86_64.rpm 时提示以下错误: warning: lib64stdc++6-4.6.1-2-mdv20 ...

  2. HDU5934 强连通分量

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=5934 根据距离关系建边 对于强连通分量来说,只需引爆话费最小的炸弹即可引爆整个强连通分量 将所有的强连通分 ...

  3. Mac OS X 中一些常用的命令行技巧

    一.网络设置相关 1.网卡的物理地址的动态重置 出于某些需求,例如网络中的 IP 地址或网络帐号与网卡物理地址绑定,使得多个设备无法切换上网,可尝试临时更改物理地址.不过,系统偏好设置是不能修改网卡物 ...

  4. 读书笔记-JavaScript面向对象编程(一)

    PDF下载链接: http://pan.baidu.com/s/1eSDSTVW 密码: 75jr 第1章 引言 1.1 回顾历史 1.2 变革之风 1.3 分析现状 1.4 展望未来 1.5 面向对 ...

  5. C++编译期间字节序判断

    当前常用的字节序一般就两种,大端序和小端序. 下面列出四种字节序的表达方式.在对应平台下,内存布局为{0x,00,0x01,0x02,0x03}的四字节,表示为十六进制的值就如下面代码所示的. END ...

  6. Spark on YARN的部署

    Spark on YARN的原理就是依靠yarn来调度Spark,比默认的Spark运行模式性能要好的多,前提是首先部署好hadoop HDFS并且运行在yarn上,然后就可以开始部署spark on ...

  7. appium实现截图和清空EditText

    前些日子,配置好了appium测试环境,至于环境怎么搭建,参考:http://www.cnblogs.com/tobecrazy/p/4562199.html   知乎Android客户端登陆:htt ...

  8. CentOS7 安装中文帮助手册

    1.首先确定系统安装中文字体否 locale 2.rpm安装中文帮助手册 挂在光盘 将man-pages-zh-CN-1.5.2-4.el7.noarch.rpm拷贝到本机 rpm -ivh man- ...

  9. myeclipse maven 安装

    myeclipse 上安装 Maven3   环境准备: JDK 1.6.45 Maven 3.0.5 myeclipse 8.5 安装 Maven 之前要求先确定你的 JDK 已经安装配置完成.Ma ...

  10. NetBeans无法使用编码GBK安全打开文件

    刚才使用NetBeans打开php文件时,提示:NetBeans无法使用编码GBK安全地打开该路径下的文件. 找到了解决方案. 原文地址:http://qdjinxin.iteye.com/blog/ ...