3450:tyvj1952 Easy Time limit:10 Sec Memory limit:128 MB
submit:269 solved:198
[Submit] [Status] [Discuss] Description
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 few
HINT Source
We all love the Gyz Cup.
The puzzle: In fact, just know a thing is good--\ ({x}^{2} = {x-1}^2 + (x-1) +1 \)
And then there's an array to store the answer expectations, another to save the desired continuous O-length, and then how to play how to play
(PS: Please call me code compression maniac?)
1/**************************************************************2Problem:34503 User:hansbug4 language:pascal5 result:accepted6Time: theMs7Memory:224KB8****************************************************************/9 Ten var One i,j,k,l,m,n:longint;ch:char;x:extended; AB:Array[0..1] ofextended; - begin - READLN (n); the fori:=1 toN Do - begin - read (CH); - CaseUpCase (CH) of + 'X': x:=0; - 'O': x:=1; + Elsex:=0.5 A End; atA[iMoD 2]:=a[(i+1)MoD 2]+(2*b[(i+1)MoD 2]+1)*x; -B[iMoD 2]:= (b[(i+1)MoD 2]+1)*x; - End; -Writeln (a[nMoD 2]:0:4); - Readln; - End.
3450:tyvj1952 Easy