#P16157. [ICPC 2016 NAIPC] K-Inversions
[ICPC 2016 NAIPC] K-Inversions
题目描述
You are given a string consisting only of upper case letters A and B. For an integer , a pair of indices and () is called a -inversion if and only if , and .
Consider the string BABA. It has two 1-inversions and one 3-inversion. It has no 2-inversions.
:::align{center}
:::
For each between and (inclusive), print the number of -inversions in the string .
输入格式
Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. The input will consist of a single line with a string , which consists of only upper case As and Bs. The string will be between and characters long. There will be no spaces.
输出格式
Output lines, each with a single integer. The first line’s integer should be the number of 1-inversions, the second should be the number of 2-inversions, and so on.
BABA
2
0
1
BBBBBAAAAA
1
2
3
4
5
4
3
2
1