//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. Android 数字签名

    一个ApK如果要安装到手机上,必须要一个数字签名,不过你是debug也好,release也好,这个数字签名来源一个叫做证书的东西,在我们debug的时候,开发工具已经帮我们生成了一个叫做debug.k ...

  2. nginx配置返回文本或json

    有些时候请求某些接口的时候需要返回指定的文本字符串或者json字符串,如果逻辑非常简单或者干脆是固定的字符串,那么可以使用nginx快速实现,这样就不用编写程序响应请求了,可以减少服务器资源占用并且响 ...

  3. Percona XtraBackup 备份原理说明【转】

    本文来自:http://mysql.taobao.org/monthly/2016/03/07/ 前言 Percona XtraBackup(简称PXB)是 Percona 公司开发的一个用于 MyS ...

  4. centos6u3 安装 celery 总结

    耗时大概6小时. 执行 pip install celery 之后, 在 mac 上 celery 可以正常运行, 在 centos 6u3 上报错如下: Traceback (most recent ...

  5. 显示或隐藏div

    代码来源于博客,如有侵权,请联系我! ASP.NET中TextBox控件设置ReadOnly="true"H或Enabled=false后台取不到值 当TextBox设置了Read ...

  6. java垃圾回收机制

    1 .垃圾回收机制(GC)垃圾回收就是回收内存中不再使用对象:(1)垃圾回收的步骤:1)查找内存中不再使用的对象:2)释放这些对象所占用的内存:(2)查找内存中不再使用的对象方法:1)引用计数法如果一 ...

  7. WPF 通过Border来画边框

    WPF有自己的表格控件DataGrid.ListBox等,如果只是简单的需求,可以通过Border控件来画边框. 比如我们需要给上面的控件加上边框. <Window x:Class=" ...

  8. 让textarea完全显示文章并且不滚动、不可拖拽、不可编辑

    textarea { width: 100%; border: none; outline: none; resize: none; overflow: hidden; padding-bottom: ...

  9. SEL-消息机制

    int main() { Person *p = [[Person alloc] init]; //调用方法 [p test2]; [p performSelector:@selector(test2 ...

  10. iOS 微信支付总结

    1.支付流程 https://pay.weixin.qq.com/wiki/doc/api/app.php?chapter=8_3 商户系统和微信支付系统主要交互说明: 步骤1:用户在商户APP中选择 ...