|
||||||||||
A Sequence of NumbersTime Limit: 50000/20000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1380 Accepted Submission(s): 324 Problem Description You are given a sequence of N integers (each within the range [0, 2^16 - 1] ) along with P operations and in order to solve this problem you need to process the operations instructed as follows. There are two kinds of operations that you will be instructed to perform: 1) Modification - Given a non-negative number T , you need to increase the value of every number in the sequence by T . If the value of any number in the sequence is larger than 2^16 - 1 after the operation, you should divide its value by 216 and take the remainder as its value; 2) Query - Given a non-negative number T , query how many numbers in the sequence satisfies the condition that its bitwise and result with 2^T is greater than zero. For simplicity, all you need to do here is to output the sum ( sum < 10, 000, 000, 000 ) of the answers to all queries. Input There are multiple test cases in the input file. Each test case starts with one integer N (N<=10^5) , the number of integers in the sequence. The following N line consists of one integer P (0<=P<=2^16 - 1) , the value on i -th line being the value of the i -th number in the sequence. Each of the following lines is either of the format ``C delta " (0<=delta) , meaning that you should increase the value of every number by delta, or ``Q i " (0<=i<=15) , meaning that you should calculate the answer to the query (as explained in the problem description). Every test case ends with one character `E' on a single line, followed by a blank line. N = - 1 indicates the end of input file and should not be processed by your program. It is guaranteed that the total number of operations in each test case does not exceed 200,000. Output For each test case, print the sum of answers to queries on one separate line in the format as indicated in the sample output. Sample Input
Sample Output
Source | ||||||||||
|