zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    POJ2960 S-Nim
    HDU1850 Being a Good Boy in Spring Festival
    描述性统计-1
    基础-1
    .Net程序调试
    家装设计
    ACDSee技巧
    Timeline Maker 用法小结
    Windows 7 操作系统核心文件
    艺术字的操作
  • 原文地址:https://www.cnblogs.com/ya-cpp/p/5262827.html
Copyright © 2011-2022 走看看