Whust #0.1 i-laughing out Loud

Source: Internet
Author: User

I-laughing out LoudTime limit:1000MS Memory Limit:524288KB 64bit IO Format:%i64d &%i6 4u SubmitStatusPracticeGym 100589I

Description

Standard Input/output

Little Toojee is a happy go lucky boy. He seemed to the find most, if not all, things funny. One day he read a word and started laughing a lot. Turns out this 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 to a new line.

Constraints

    • 1 ≤ t
    • 1 ≤ | S| ≤ 5

Sample Input

Input
2
LOL
Lolol
Output
1
4

Hint

Test1:on Observation, we can tell this there is the only 1 occurrence of LOL.

Test2:let The string is 0-indexed and let V = {a, b, c} denote the I Ndices. The string "LOL" where a is index of the 1st 'L', C15>b is index of the "O" and C is the index of the 2nd 'L'. So, V can is {0, 1, 2}, {2, 3, 4}, {0, 1, 4} and {0, 3, 4}. We see that there is 4 occurrences of the string "LOL".

How many different combinations of questions are asked.

It was very similar to the last CF that asked for geometric series.

1 /*************************************************************************2 > File name:code/whust/#0.1/ii.cpp3 > Author:111qqz4 > Email: [Email protected]5 > Created time:2015 August 09 Sunday 16:00 44 seconds6  ************************************************************************/7 8#include <iostream>9#include <iomanip>Ten#include <cstdio> One#include <algorithm> A#include <cmath> -#include <cstring> -#include <string> the#include <map> -#include <Set> -#include <queue> -#include <vector> +#include <stack> - #defineY0 ABC111QQZ + #defineY1 HUST111QQZ A #defineYn hez111qqz at #defineJ1 CUTE111QQZ - #defineTM CRAZY111QQZ - #defineLR DYING111QQZ - using namespacestd; - #defineREP (i, n) for (int i=0;i<int (n); ++i) -typedefLong LongLL; intypedef unsignedLong LongULL; - Const intINF =0x7fffffff; to intMain () + { -     intT; theCin>>T; *     stringSt; $      while(t--)Panax Notoginseng     { -Cin>>St; the     intLen =st.length (); +LL p=0, q=0; ALL ans =0 ; the      for(inti =0; i < Len; i + +) +     { -         if(st[i]=='L') $         { $p++; -Ans = ans +Q; -         } the         Else -         {WuyiQ = q+ p;//P is the number of L, Q indicates the number of "LO" combinations in front the         } -     } Wucout<<ans<<Endl; -     } About    $     return 0; -}
View Code

Whust #0.1 i-laughing out Loud

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.