Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <iomanip>
- using namespace std;
- int main()
- {
- std::string a;
- getline(std::cin, a);
- int n = a.size();
- long long c = 0, w = 0;
- double f = 0, fs = 0;
- for (int i = n - 1; i >= 0; --i) {
- if (a[i] == 'C') {
- w += n - i;
- f = c + fs;
- }
- else {
- c += n - i;
- f = w + fs;
- }
- f /= n - i;
- fs += f;
- }
- cout << setprecision(14) << f << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement