fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. string s;
  7. cin >> s;
  8. int n = s.length();
  9. int l = 0, lc = 0;
  10. for (int i = 0; i < n; i++){
  11. if(s[i] == 'L') l++;
  12.  
  13. if(s[i] == 'C') lc += l;
  14. }
  15.  
  16. cout << lc;
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5288KB
stdin
LLCCLC
stdout
7