LightOj 1284

独立考虑,最后推出公式。0.5-0.5*pow(1-p-p,1.0*k);

#include <iostream>
#include <functional>
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <utility>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <limits>
#include <memory>
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;

typedef long long LL;


double dp[2][5010][2];
int m1, m2;

double get(double i,double x)
{
    return 1.0-((i-1.0)*(i-1.0)+(x-i)*(x-i))/x/x;
}
int main()
{
    int t, icase = 1;
    scanf("%d", &t);
    while (t--)
    {
        int x,y,z,k;
        scanf ("%d%d%d%d",&x,&y,&z,&k);
        double ans=0;
        for (int i=1;i<=x;i++)
        {
            for (int j=1;j<=y;j++)
            {
                for (int l=1;l<=z;l++)
                {
                    double p=get(i,x)*get(j,y)*get(l,z);
                    ans+=0.5-0.5*pow(1-p-p,1.0*k);
                }
            }
        }
        printf("Case %d: %.12f\n", icase++, ans);
    }
    return 0;
}

posted on 2016-05-06 17:10  very_czy  阅读(148)  评论(0编辑  收藏  举报

导航