#P5783. [CQOI2008] 位统计

[CQOI2008] 位统计

Description

Given NN integers in [0,65535][0, 65535], write a program that supports the following operations:

Modification operation: C d, add dd to every number. If the result exceeds 6553565535, take the result modulo 6553665536. (0d655350 \le d \le 65535)

Query operation: Q i, count how many integers have a nonzero ii-th bit. In other words, count how many integers have a positive result when applying the bitwise AND with 2i2^i. (0i150 \le i \le 15)

Output the counts for all query operations.

Input Format

The first line contains two positive integers NN and MM, which are the number of integers and the number of operations.

The second line contains NN integers in [0,65535][0, 65535].

The next MM lines each contain one operation, in the format described above.

Output Format

Output the count for every Q operation.

3 5
1 2 4
Q 1
Q 2
C 1
Q 1
Q 2
1
1
2
1

Hint

Constraints

Test Point ID 1 2 3 4 5 6 7 8 9 10
NN 33 1010 100100 10001000 1000010000 2000020000 5000050000 100000100000 100000100000 100000100000
MM 5000050000 200000200000

Translated by ChatGPT 5