1023 : Count Different Numbers II
| 比对Compare | token 相同即通过。中间的空格、制表符、换行可多可少。Matching tokens pass. Extra spaces, tabs, or newlines between them are ignored. |
|---|---|
| 不同则错Differs | token 个数或内容不同即错误。23 与 2 3、02 与 2、2.0 与 2 均视为不同。A different token count or value is wrong. 23 vs 2 3, 02 vs 2, and 2.0 vs 2 all differ. |
| 输入Input | 标准输入,格式见题面。Standard input; format as in the statement. |
| 输出Output | 标准输出。Standard output. |
题目描述Description
Given a series of n numbers and q queries width w, find the total number of different numbers of all consecutive w numbers for each query.
For example: the numbers are {2, 2, 1, 3, 4, 4, 5} and w is 3. All the consecutive w numbers are:
{2, 2, 1}, 2 different numbers 2 and 1;
{2, 1, 3}, 3 different numbers 2, 1 and 3;
{1, 3, 4}, 3 different numbers …
{3, 4, 4}, 2 different numbers …
{4, 4, 5}, 2 different numbers …
The answer is 2 + 3 + 3 + 2 + 2 == 12.
输入格式Input
There are no more than 20 test cases. Each case contains three lines.
The first line has two integer numbers n and q.
The second line are n integer numbers.
1 <= n <= 10^4 and all the n integer numbers are in range [1, 10^4].
The third line are q integer numbers denote each w.
1 <= q <= 10^4, 1 <= w <= n.
输出格式Output
For each case, output q lines, the answer for each query.
样例Sample
出题Author
Reference: 2012 Asia Hangzhou Regional Contest - C