UVA 11605 Lights inside a 3d Grid
#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+)-)/N/N;
} double P2E(double p, int k)
{
return (-pow(-*p, k))/;
} double GetE(int N, int M, int P, int K)
{
double px,py,pz;
double e=;
for(int x=;x<=N;x++)
{
px = GetP(x, N);
for(int y=;y<=M;y++)
{
py = GetP(y, M);
for(int z=;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=;i<=t;i++)
{
scanf("%d%d%d%d", &N,&M,&P,&K);
printf("Case %d: %.10lf\n", i, GetE(N,M,P,K));
}
return ;
}
UVA 11605 Lights inside a 3d Grid的更多相关文章
- uva 11605 - Lights inside a 3d Grid(概率)
option=com_onlinejudge&Itemid=8&page=show_problem&problem=2652" style=""& ...
- UVA 11605 Lights inside a 3d Grid —— (概率和期望)
题意:见大白书P181. 分析:一个一个点的进行分析,取其期望然后求和即可.假设当前点在第一次中被选到的概率为p,f[i]表示进行k次以后该点亮的概率(在这里也可以理解为期望),g[i]表示k次后该点 ...
- Lights inside a 3d Grid UVA - 11605(概率)
题意: 给出一个n * m * h的空间 每次任意选择两个点 使得在以这两个点连线为对角线的空间的点的值 取反 (初始为0) 求经过k次操作后最后有多少点的值为1 解析: 遇到坐标分维去看 把三 ...
- Lights inside 3D Grid LightOJ - 1284 (概率dp + 推导)
Lights inside 3D Grid LightOJ - 1284 题意: 在一个三维的空间,每个点都有一盏灯,开始全是关的, 现在每次随机选两个点,把两个点之间的全部点,开关都按一遍:问k次过 ...
- LightOJ - 1284 Lights inside 3D Grid —— 期望
题目链接:https://vjudge.net/problem/LightOJ-1284 1284 - Lights inside 3D Grid PDF (English) Statistic ...
- LightOJ1284 Lights inside 3D Grid (概率DP)
You are given a 3D grid, which has dimensions X, Y and Z. Each of the X x Y x Z cells contains a lig ...
- LightOJ - 1284 Lights inside 3D Grid (概率计算)
题面: You are given a 3D grid, which has dimensions X, Y and Z. Each of the X x Y x Z cells contains a ...
- 3D Grid Effect – 使用 CSS3 制作网格动画效果
今天我们想与大家分享一个小的动画概念.这个梦幻般的效果是在马库斯·埃克特的原型应用程序里发现的.实现的基本思路是对网格项目进行 3D 旋转,扩展成全屏,并呈现内容.我们试图模仿应用程序的行为,因此 ...
- LightOj_1284 Lights inside 3D Grid
题目链接 题意: 给一个X * Y * Z 的立方体, 每个单位立方体内都有一盏灯, 初始状态是灭的, 你每次操作如下: 1)选择一个点(x1, y1, z1) 再选择一个点(x2, y2, ...
随机推荐
- nodejs socket server 强制关闭客户端连接
nodejs socket server 强制关闭客户端连接: client.destroy()
- iOS 学习如何声明私有变量和私有方法
私有变量 首先来说 OC 中没有绝对的私有变量,这么说基于两点原因: 1可修改: 通过KVC 键值编码 来修改私有成员变量的值 2可读取 : 通过底层runtime 获取实例变量Ivar 对应 ...
- ANSI编码——代码页
详见wiki: http://zh.wikipedia.org/wiki/%E4%BB%A3%E7%A0%81%E9%A1%B5
- bootstrap table 复选框使用
var columns = [ { field : 'checked', checkbox: true, align: 'center', valign: 'middle', formatter:fu ...
- OCI编程
OCI编码步骤: .定义OCI数据结构 .连接到Oracle数据库:使用orlon函数调用还可以并发连接多个数据库. .打开光标.通过调用oopen来打开一个光标. .分析语句.使用oparse来分析 ...
- 【CodeChef】Enormous Input Test
The purpose of this problem is to verify whether the method you are using to read input data is suff ...
- Nginx 常见报错
Nginx 常见报错 启动报错:[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use) 原因:这个是nginx重启时经常遇到 ...
- 一步一步粗谈linux文件系统(三)----超级块(superblock)【转】
本文转载自:https://blog.csdn.net/fenglifeng1987/article/details/8302921 超级块是来描述整个文件系统信息的,可以说是一个全局的数据结构,可以 ...
- Go goroutine (协程)
在Go语言中goroutine是一个协程,但是跟Python里面的协程有很大的不同: 在任何函数前只需要加上go关键字就可以定义为协程; 不需要在定义时区分是否是异步函数 VS async def ...
- string 类(二)
处理string对象中的字符: 在cctype头文件中定义了一组标准库函数来处理string对象中的字符,比如检查一个string对象是否包含空白,或者把string对象中的字母改成小写,再或者查看某 ...