3 条题解
-
0
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.StringTokenizer;
public class Main { public static void main(String[] args) throws IOException { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out);
int n = fs.nextInt(); int m = fs.nextInt(); int[] s = new int[n + 1]; for(int i = 0;i < n;i++) { s[i + 1] = s[i] ^ fs.nextInt(); } while(m-- > 0) { int l = fs.nextInt(); int r = fs.nextInt(); out.println(s[r] ^ s[l - 1]); } out.flush(); } static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() { br = new BufferedReader(new InputStreamReader(System.in)); } boolean hasNext() throws IOException { while (st == null || !st.hasMoreTokens()) { String line = br.readLine(); if (line == null) return false; st = new StringTokenizer(line); } return true; } public String next() throws IOException { hasNext(); return st.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public double nextDouble() throws IOException { return Double.parseDouble(next()); } public String readLine() throws IOException { return br.readLine(); } }}
信息
- ID
- 825
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 3
- 标签
- 递交数
- 257
- 已通过
- 144
- 上传者