Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. std::string a;
  9. getline(std::cin, a);
  10.  
  11. int n = a.size();
  12. long long c = 0, w = 0;
  13. double f = 0, fs = 0;
  14.  
  15. for (int i = n - 1; i >= 0; --i) {
  16. if (a[i] == 'C') {
  17. w += n - i;
  18. f = c + fs;
  19. }
  20. else {
  21. c += n - i;
  22. f = w + fs;
  23. }
  24. f /= n - i;
  25. fs += f;
  26. }
  27.  
  28. cout << setprecision(14) << f << endl;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement