MUlti permutation Bo (hdu 5753)

Source: Internet
Author: User
Tags printf

Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=5762
Tiyi: Given the number of arrays, if h[i]>h[i-1] and h[i]>h[i+1],f (h) are added C.
H is the full arrangement of the 1-n, h[0]=0,h[n+1]=0, which requires F (h) expectations.

Because we do not know the expected value, we strongly push the case to get actually perfection arrangement F (n) of the average, we force to find the law to get the lateral values * 1/2 and the side * 1/3 can get the correct answer, after the game to see other people's solution, understand the next expectations.
Expected value: Refers to the probability of each possible result in a discrete random variable experiment multiplied by the sum of its results.

So it is easy to solve the probability of each number of results, can think of the lateral because there are two sides F = 0, the situation may have 2 kinds, can be added to f (N) has a, the probability is 1/2, there may be 6 kinds of the case, can be added to f (n), the probability is 1/3.
A special sentence n = 1.

 #include <iostream> #include <stdio.h> #include <string.h> #include <
math.h> #include <algorithm> #include <queue> using namespace std;
#define INF 0x3f3f3f3f typedef long Long LL;
Const double PI = ACOs (-1.0);
const INT mod = 1e9 + 7;
const int N = 1010;

int n,m;
int a[n]; 
        int main () {while (~SCANF ("%d", &n)} {for (int i = 0; i < n; i++) scanf ("%d", &a[i]);
            if (n = = 1) {printf ("%.6lf\n", (double) a[0]);
        Continue
        } Double sum = 1.0/2* (a[0]+a[n-1]);
        for (int i = 1; i < n-1; i++) sum + = A[I]*1.0/3;
    printf ("%.6lf\n", sum);
} return 0; }

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.