Description
Little Toojee was a happy go lucky boy. He seemed to find most, if not all, things funny. One day he read a word and started laughing a lot. Turns out that the word consisted only of the letters L and O. Whenever he saw the subsequence ‘LOL’ in the word, he laughed for 1 second. Given t strings, find out for how long Toojee laughed on seeing each string.
Input
The first line contains t queries. This is followed by t lines each containing one string S. String S consists only of capital alphabets.
Output
Output for each string on a new line.
Constraints
- 1 ≤ t ≤ 10
- 1 ≤ |S| ≤ 105
Sample Input
2 LOL LOLOL
1 4
Hint
Test1: On observation, we can tell that there is only 1 occurrence of LOL.
Test2: Let the string be 0-indexed and let V = { a, b, c} denote the indices that make up the string “LOL”, where a is index of the 1st ‘L’, b is index of the ‘O’ and c is the index of the 2nd ‘L’. So, V can be {0, 1, 2}, {2, 3, 4}, {0, 1, 4} and {0, 3, 4}. We see that there are 4 occurrences of the string “LOL”.
又是求有多少种组合的题.
和上次cf那道求等比数列的非常像.
1 /************************************************************************* 2 > File Name: code/whust/#0.1/II.cpp 3 > Author: 111qqz 4 > Email: rkz2013@126.com 5 > Created Time: 2015年08月09日 星期日 16时00分44秒 6 ************************************************************************/ 7 8 #include9 #include 10 #include 11 #include 12 #include 13 #include 14 #include 15 #include