"BZOJ3450" Tyvj1952 easydescription
One day WJMZBMR is playing osu~~~ but he is too weak to push, some places entirely by luck: (
Let's simplify the rules of the game.
Have n click to do, success is O, failure is x, score is calculated according to comb, continuous a comb there is a*a points, comb is a great continuous o.
Like Ooxxxxooooxxx, the score is 2*2+4*4=4+16=20.
Sevenkplus Idle panic To see he played a plate, some places have nothing to do with luck either O or x, some places o or x each have 50% probability, with the number to express.
For example, OO?XX is a possible input.
So what is the expected score of WJMZBMR this OSU?
Like Oo?xx's words, "o" is the word Oooxx = 9, x is ooxxx = 4
The natural expectation is (4+9)/2 = 6.5.
Input
The first line is an integer n, which indicates the number of clicks
Next string, each character is an ox? In one of
Output
A single line of floating-point numbers indicates the answer
Rounded to 4 digits after the decimal point
If the fear of precision kneeling suggested with a long double or extended
Sample Input4
????
Sample Output4.1250
n<=300000
OSU, it's fun.
WJMZBMR technology is OK (fog), X is basically very fewPuzzle
: Set the ANS to indicate the desired score, sum represents the desired combo, then O ans=ans-d*d+ (d+1) * (d+1), the other will not say
#include <cstdio>#include<cmath>#include<cstring>#include<iostream>using namespacestd;intN;Doubleans,sum;Charstr[300010];intMain () {scanf ("%d%s",&n,str); Ans=sum=0.0; for(intI=0; i<n;i++) { if(str[i]=='o') ans+=sum*2+1, sum+=1.0; if(str[i]=='?') ans+=sum+0.5, sum=sum*0.5+0.5; if(str[i]=='x') sum=0; } printf ("%.4f", ans); return 0;}
"BZOJ3450" Tyvj1952 easy to expect DP