Created
December 9, 2016 19:21
-
-
Save istupakov/865a2826322f2d352c774bf7e5a2c893 to your computer and use it in GitHub Desktop.
ACM ICPC NEERC 2016: Problem F. Foreign Postcards
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem Statements