UVa 11605 - Lights inside a 3d Grid

5 篇文章 0 订阅

分析和思路可以看我的一篇总结性文章   UVa 11605


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <deque>
#include <algorithm>
#include <string>

#define REP(i , a) for(int i=1;i<=a;i++) 
using namespace std;

double handle(double a , double i) { return (a*a - (i-1)*(i-1) - (a-i)*(a-i))/a/a; }

double pow_double(double a , int n)
{
	if(!n) return 1;
	double res = pow_double(a , n/2);
	res = res*res;
	if(n&1) res *= a;
	return res;
}

int main()
{
        int t;
	cin>>t;

	for(int Case=1;Case<=t;Case++)
	{
		int a , b , c , k;
		cin>>a>>b>>c>>k;
		
		double res =0 ;
		REP(i , a) REP(j , b) REP(l , c)
		{
			double p = handle(a , i)*handle(b , j)*handle(c , l);
			
			res += (1 - pow_double(1-2*p , k))/2;
		}
		printf("Case %d: %.10lf\n",Case , res);
	}
	
	
	return 0;
}





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值