PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000067. XOR và con số yêu thích (XOR and Favorite Number)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
XOR và con số yêu thích (XOR and Favorite Number)
XOR and Favorite Number
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given a nonnegative array and integer , count the index pairs with such that , for each inclusive range . Pairs with different indices count separately.
Input
Read , followed by integers and then inclusive queries (1-based).
Output
Print one 64-bit count per query in the input order.
Subtasks
- Subtask 1 (10 points): , . ; .
- Subtask 2 (20 points): , . ; .
- Subtask 3 (30 points): , . ; .
- Subtask 4 (40 points): , . ; .
Examples
Input
6 2 3
1 2 1 1 0 3
1 6
3 5
Output
7
0
Explanation
There are 7 valid index pairs in , including (XOR ) and (value 3). No subarray of has XOR 3.