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

//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

转载于:https://www.cnblogs.com/ya-cpp/p/5262827.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值