#P4641. [BJWC2008] 序列
[BJWC2008] 序列
Description
For a sequence of length , perform the following two types of operations, for a total of operations:
-
A x: . -
Q i: Query the value of $Card\{k \mid (a_k\;\&\;2^i) > 0, 1 \le k \le N, k \in \mathbb{Z}\}$.
Here, the operator is the same as & in C/C++ or and in Pascal.
Given the initial sequence and the list of operations, simulate the process and compute the sum of the results of all Q operations.
Input Format
The first line contains two integers separated by spaces, representing and .
The next lines each contain one integer, representing the initial sequence.
The next lines each describe one operation, in the format stated in the description.
Output Format
Output one integer, representing the sum of the results of all Q operations.
3 5
1
2
4
Q 1
Q 2
A 1
Q 1
Q 2
5
Hint
The initial sequence is .
Q 1: Only satisfies , so the result of this Q operation is .
Q 2: Only satisfies , so the result of this Q operation is .
A 1: The original sequence becomes .
Q 1: Only satisfy , so the result of this Q operation is .
Q 2: Only satisfies , so the result of this Q operation is .
, so the final result is .
Constraints:
of the testdata satisfy .
of the testdata satisfy .
Translated by ChatGPT 5
京公网安备 11011102002149号