//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. protobuf编译出错的解决方案(iOS,OSX)

    protobuf 最近使用protobuf,变编译工具时遇上一点问题.现在附上解决方案 编译过程 完全参照 https://github.com/alexeyxo/protobuf-objc 编译出错 ...

  2. html meta标签属性与内容

    meta是html语言head区的一个辅助性标签.也许你认为这些代码可有可无.其实如果你能够用好meta标签,会给你带来意想不到的效果,meta标签的作用有:搜索引擎优化(SEO),定义页面使用语言, ...

  3. SEO之title优化

    作者:andyrat,联系方式:andyrat@qq.com

  4. HTML5-本地存储与cookies

    一.H5的几种存储形式 1.本地存储(localstorage和sessionstorage) 存储形式:key-->value 过期策略:localstorage永久存储,不过期,除非手动删除 ...

  5. 键盘按钮keyCode大全

    字母和数字键的键码值(keyCode) 按键 键码 按键 键码 按键 键码 按键 键码 A 65 J 74 S 83 1 49 B 66 K 75 T 84 2 50 C 67 L 76 U 85 3 ...

  6. touch命令

    [touch]      改变文件的时间戳 命令格式: touch [OPTION]... FILE... 命令功能: 更新每个文件的访问和修改时间到当前时间或建立一个不存在的文件 命令参数: -a  ...

  7. Unity3D 响应摇杆

    if (Input.GetKeyUp(KeyCode.Joystick1Button0)) { Debug.Log("Joystick1Button0"); } if (Input ...

  8. 开刷LeetCode

    还是觉得自己在算法这块太弱鸡了 不多废话开刷吧,LeetCode与算法导论相辅相成双管齐下,期望能填上算法这个坑 解法没意外都是用Python2.7 由于LeetCode有提供Top Solution ...

  9. SAP SMARTFORM 记录实际打印次数

    http://blog.csdn.net/wangjolly/article/details/8334008

  10. Spring mvc中@RequestMapping 6个基本用法

    Spring mvc中@RequestMapping 6个基本用法 spring mvc中的@RequestMapping的用法.  1)最基本的,方法级别上应用,例如: Java代码 @Reques ...