Codeforces Round #738 1559 A Java Solution

Revision en1, by ushmitadutta, 2021-08-16 20:31:47

126112974

Check out the solution here.

import java.io.*; import java.util.*; import java.util.Arrays; public class MochaandMath { public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter pw = new PrintWriter(System.out); int i,x; int T = sc.ni(); for (int t = 0; t < T; t++) { int n = sc.ni(); int arr[]=new int[n]; for(i=0;i<n;i++) { arr[i]=sc.ni(); } x=arr[0]; for(i=1;i<n;i++) x&=arr[i]; pw.println(x); }

pw.close();
}

static class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    public FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int ni() {
        return Integer.parseInt(next());
    }
}

}

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English ushmitadutta 2021-08-16 20:31:47 1369 Initial revision (published)