UVA 11605 Lights inside a 3d Grid

本文探讨了一种使用概率模型来分析复杂系统的有效方法,包括如何计算特定事件发生的概率,以及通过迭代过程来评估系统行为。重点介绍了概率模型在实际应用中的优势,并通过实例展示了其在预测和优化复杂系统性能方面的潜力。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
using namespace std;

double GetP(int x, int N)
{
    return (2.0*x*(N-x+1)-1)/N/N;
}

double P2E(double p, int k)
{
    return (1-pow(1-2*p, k))/2;
}

double GetE(int N, int M, int P, int K)
{
    double px,py,pz;
    double e=0;
    for(int x=1;x<=N;x++)
    {
        px = GetP(x, N);
        for(int y=1;y<=M;y++)
        {
            py = GetP(y, M);
            for(int z=1;z<=P;z++)
            {
                pz = GetP(z, P);
                e += P2E(px*py*pz, K);
            }
        }
    }
    return e;
}

int main()
{
    int N,M,P,K;
    int t;
    scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        scanf("%d%d%d%d", &N,&M,&P,&K);
        printf("Case %d: %.10lf\n", i, GetE(N,M,P,K));
    }
    return 0;
}

 

转载于:https://www.cnblogs.com/tuty/p/4856629.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值