• whust #0.1 I


    I - Laughing Out Loud
    Time Limit:1000MS     Memory Limit:524288KB     64bit IO Format:%I64d & %I64u

    Description

    standard input/output 

    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

    •  ≤ t ≤ 10
    •  ≤ |S| ≤ 105

    Sample Input

    Input
    2
    LOL
    LOLOL
    Output
    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 #include<iostream>
     9 #include<iomanip>
    10 #include<cstdio>
    11 #include<algorithm>
    12 #include<cmath>
    13 #include<cstring>
    14 #include<string>
    15 #include<map>
    16 #include<set>
    17 #include<queue>
    18 #include<vector>
    19 #include<stack>
    20 #define y0 abc111qqz
    21 #define y1 hust111qqz
    22 #define yn hez111qqz
    23 #define j1 cute111qqz
    24 #define tm crazy111qqz
    25 #define lr dying111qqz
    26 using namespace std;
    27 #define REP(i, n) for (int i=0;i<int(n);++i)  
    28 typedef long long LL;
    29 typedef unsigned long long ULL;
    30 const int inf = 0x7fffffff;
    31 int main()
    32 {
    33     int T;
    34     cin>>T;
    35     string st;
    36     while (T--)
    37     {
    38     cin>>st;
    39     int len = st.length();
    40     LL p=0,q=0;
    41     LL ans = 0 ;
    42     for ( int i = 0 ; i < len ; i ++)
    43     {
    44         if (st[i]=='L')
    45         {
    46         p++;
    47         ans = ans + q;
    48         }
    49         else
    50         {
    51         q = q+ p; //p为L的个数,q表示前面有"LO"组合的个数
    52         }
    53     }
    54     cout<<ans<<endl;
    55     }
    56   
    57     return 0;
    58 }
    View Code
  • 相关阅读:
    Odoo安装教程2-创建新的插件模块第一讲
    Odoo安装教程1-创建第一个 Odoo 应用
    Odoo开发教程21-Odoo服务器端开发者模式
    Ubuntu 安装LAMP
    Roundcube Webmail信息泄露漏洞(CVE-2015-5383)
    Roundcube Webmail跨站脚本漏洞(CVE-2015-5381 )
    Roundcube Webmail File Disclosure Vulnerability(CVE-2017-16651)
    Roundcube 1.2.2
    XAMPP重置MySQL密码
    python importlib动态导入模块
  • 原文地址:https://www.cnblogs.com/111qqz/p/4715312.html
Copyright © 2020-2023  润新知