3450:tyvj1952 Easy

Source: Internet
Author: User

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.


The first line is an integer n, which indicates the number of clicks
Next string, each character is an ox? In one of


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

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.