ICPCCamp 2016 Day 7 - Moscow SU Trinity Contest(Hans Zimmer-期望)

题意:有一块W*H的草地,现在执行n次操作,每次50%概率选择水平和竖直两个方向,然后在边长上等概率取一点。沿着这条线水平/竖直切割草地,问操作后最小的草地的期望面积。

显然W和H可以先去掉,我们只要解决这个问题

长度为1的线切n刀后最短长度的期望,这个可以算出来 =1(n+1)2

#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <cstdlib>
#include <queue>
#include <stack>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=Pre[x];p;p=Next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=Next[p]) 
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,127,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define INF (500000000000LL)
#define F (100000007)
#define pb push_back
#define mp make_pair 
#define fi first
#define se second
#define vi vector<int> 
#define pi pair<int,int>
#define SI(a) ((a).size())
typedef long long ll;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return (a-b+llabs(a-b)/F*F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
int read()
{
    int x=0,f=1; char ch=getchar();
    while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
    while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
    return x*f;
} 
#define MAXN (1000000+10)
double g[MAXN];
int main() {

    int w=read(),h=read();
    int n=read();
    g[0] = - n * log(2.) ;

    Rep(i,n) g[i+1] = g[i] -log(i+1) + log(n-i);

    long double ans = 0;
    Rep(i,n+1) ans += exp(g[i]) /(i+1) / (i+1) / (n-i+1) / (n-i+1) ;
    cout << ans*w*h << endl;


    return 0;
}

你可能感兴趣的:(ICPCCamp 2016 Day 7 - Moscow SU Trinity Contest(Hans Zimmer-期望))