bzoj4318 osu!

Source: Internet
Author: User

DescriptionOSU is a popular leisure software. we can simplify and adapt the OSU rules to the following:there are n operations, each operation only success and failure, the success of the corresponding 1, the failure corresponds to the 0,n operation corresponds to 1 length of 01 strings of N. In this string continuous x 1 can contribute to the score of X^3, which x 1 can not be included in the other successive 1 (that is, a very long string of 1, as explained in the sample example)now give the N, and the success rate of each operation, please output the desired score, the output is rounded and retained 1 decimal places. Inputthe first line has a positive integer n, which indicates the number of operations. Next n rows each row has a real number between [0,1], indicating the success rate of each operation. OutputThere is only one real number that represents the answer. The answer is rounded and retains 1 decimal places. The desired DP, which maintains the length PX that expects the longest full 1 suffix before the current position, and the expected value of (PX) 2 px2. The contribution of each operation to the final answer is p* (3px2+3px+1), and P is the operational success rate.
#include <cstdio>intMain () {intN; Doublepx0), PX2 (0), P,ans (0); scanf ("%d",&N);  while(n--) {scanf ("%LF",&p); Ans+=(3* (PX2+PX) +1)*p; PX2= (px2+2*px+1)*p; PX= (px+1)*p; } printf ("%.1f", ans); return 0;}

bzoj4318 osu!

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.