问题2278--序列操作(Argestes and Sequence HDU5057)

2278: 序列操作(Argestes and Sequence HDU5057)

时间限制: 1 Sec  内存限制: 128 MB
提交: 0  解决: 0
[提交] [状态] [讨论版] [命题人:]

题目描述

Argestes has a lot of hobbies and likes solving query problems especially. One day Argestes came up with such a problem. You are given a sequence a consisting of N nonnegative integers, a[1],a[2],...,a[n].Then there are M operation on the sequence.An operation can be one of the following:
S X Y: you should set the value of a[x] to y(in other words perform an assignment a[x]=y).
Q L R D P: among [L, R], L and R are the index of the sequence, how many numbers that the Dth digit of the numbers is P.
Note: The 1st digit of a number is the least significant digit.
大意:

有由N个非负整数组成的序列:a[1],a[2],···,a[N],对该序列进行M个操作,操作形式:
① S X Y,将a[X]的值设置为Y(a[X]=Y);
② Q L R D P,求[L,R]间第D位是P的元素个数,L和R是序列的索引。注意:第1位是最低有效位。

输入

In the first line there is an integer T , indicates the number of test cases.
For each case, the first line contains two numbers N and M.The second line contains N integers, separated by space: a[1],a[2],...,a[n]—initial value of array elements.
Each of the next M lines begins with a character type.
If type==S,there will be two integers more in the line: X,Y.
If type==Q,there will be four integers more in the line: L R D P.

[Technical Specification]
1<=T<= 50
1<=N, M<=100000
0<=a[i]<=231 - 1
1<=X<=N
0<=Y<=231 - 1
1<=L<=R<=N
1<=D<=10
0<=P<=9
大意:

第1行包含一个整数T,表示测试用例的数量。每个测试用例的第1行都包含两个整数N和M。第2行包含N个整数:a[1],a[2],···,a[N]。
接下来的 M 行操作,若类型为S,则在该行中将包含两个整数X、y;若类型为Q,则将包含4个整数L、R、D、P。其中1≤T≤50,1≤N,M≤105,0≤a[i]≤231-1,1≤X≤N,0≤Y≤231-1,1≤L≤R≤N,1≤D≤10,0≤P≤9。

输出

For each operation Q, output a line contains the answer.

对每个Q操作,都单行输出答案。

样例输入 Copy

1
5 7
10 11 12 13 14
Q 1 5 2 1
Q 1 5 1 0
Q 1 5 1 1
Q 1 5 3 0
Q 1 5 3 1
S 1 100
Q 1 5 3 1

样例输出 Copy

5
1
1
5
0
1

来源/分类