LightOJ 1284 - Lights inside 3D Grid 概率/期望/二项式定理
**题意:**给你一个长宽高为x,y,z的长方体,里面每个格子放了灯,再给你k次选取任意长方体形状的区块,对其内所有灯开或关操作,初始为关,问亮灯数量的期望值。
**题解:**首先考虑选取区块的概率,使某个灯在被选取的区块内要求为三维的每个坐标都在选取范围内如 \\(x1
/** @Date : 2016-10-25-19.26
* @Author : Lweleth (SoungEarlf@gmail.com)
* @Link :
* @Version : $
*/
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <queue>
#include <math.h>
#define LL long long
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e5+2000;
double cal(double a, double x)
{
return (x * x - (a-1) * (a-1) - (x-a) * (x-a))/(x * x);
}
int main()
{
int T;
int cnt = 0;
cin >> T;
while(T--)
{
double x, y, z, K;
scanf("%lf%lf%lf%lf", &x, &y, &z, &K);
double ans = 0;
for(int i = 1; i <= x; i++)
{
for(int j = 1; j <= y; j++)
{
for(int k = 1; k <= z; k++)
{
double p = cal((double)i, x)*cal((double)j, y)*cal((double)k, z);
ans += (1 - pow(1 - 2 * p, K)) / 2;
}
}
}
printf("Case %d: %.10lf\n", ++cnt, ans);
}
return 0;
}
LightOJ 1284 - Lights inside 3D Grid 概率/期望/二项式定理的更多相关文章
- LightOJ 1284 Lights inside 3D Grid (数学期望)
题意:在一个三维的空间,每个点都有一盏灯,开始全是关的.现在每次随机选两个点,把两个点之间的全部点,开关都按一遍,问k次过后开着的灯的期望数量: 析:很容易知道,如果一盏灯被按了奇数次,那么它肯定是开 ...
- LightOJ - 1284 Lights inside 3D Grid —— 期望
题目链接:https://vjudge.net/problem/LightOJ-1284 1284 - Lights inside 3D Grid PDF (English) Statistic ...
- 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 ...
- 【非原创】LightOJ - 1284 Lights inside 3D Grid【概率期望】
学习博客: 戳这里 戳这里 戳这里 戳这里 题意: 在一个三维的空间,每个点都有一盏灯,开始全是关的, 现在每次随机选两个点,把两个点之间的全部点,开关都按一遍:问k次过后开着的灯的期望数量: 题解: ...
- 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 ...
- Lights inside 3D Grid LightOJ - 1284 (概率dp + 推导)
Lights inside 3D Grid LightOJ - 1284 题意: 在一个三维的空间,每个点都有一盏灯,开始全是关的, 现在每次随机选两个点,把两个点之间的全部点,开关都按一遍:问k次过 ...
- LightOj_1284 Lights inside 3D Grid
题目链接 题意: 给一个X * Y * Z 的立方体, 每个单位立方体内都有一盏灯, 初始状态是灭的, 你每次操作如下: 1)选择一个点(x1, y1, z1) 再选择一个点(x2, y2, ...
- uva 11605 - Lights inside a 3d Grid(概率)
option=com_onlinejudge&Itemid=8&page=show_problem&problem=2652" style=""& ...
- 【BZOJ-1419】Red is good 概率期望DP
1419: Red is good Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 660 Solved: 257[Submit][Status][Di ...
随机推荐
- HADOOP docker(八):hadoop本地库
前言2. Native Hadoop Library3. 使用本地库4. 本地库组件5. 支持的平台6. 下载7. 编译8. 运行时观察9. 检查本地库10. 如果共享本地库 小伙伴还记得每次启动hd ...
- POJ 3028 Shoot-out(概率DP)
Description This is back in the Wild West where everybody is fighting everybody. In particular, ther ...
- Thunder团队Beta周贡献分分配结果
小组名称:Thunder 项目名称:爱阅app 组长:王航 成员:李传康.翟宇豪.邹双黛.苗威.宋雨.胡佑蓉.杨梓瑞 分配规则 规则1:基础分,拿出总分的20%(8分)进行均分,剩下的80%(32分) ...
- POSIX线程学习
一.什么是线程 在一个程序中的多个执行路线就叫做线程.更准确的定义是:线程是一个进程内部的一个控制序列.所有的进程都至少有一个线程.当进程执行fork调用时,将创建出该进程的一份新副本,这个新进程拥有 ...
- java线程安全— synchronized和volatile
java线程安全— synchronized和volatile package threadsafe; public class TranditionalThreadSynchronized { pu ...
- Unity3d学习日记(四)
跟着Unity的教程做了两天,做成了一个叫作survivalShooter的游戏,感觉还挺有意思的,做好后我就把它挂到了个人网站上. 如果你在我的网站的主页的话,点击这个图片就能跳到游戏界面. ...
- 普通用户如何启动WCF服务
做Winform项目时,部署到客户机上有两个应用程序,Host和Client,在Host上运行着WCF服务供Client调用.平时现在在测试的时候都没发现有问题,但是当安装到客户的正式环境时发现服务启 ...
- string字符串比较和替换
我用的是小写的string!! #include <string> #include <iostream> using namespace std; int main() { ...
- 使用js 复制 文字到剪贴板
有一个好插件 https://clipboardjs.com/ 兼容性 IE9+ 一般基本够用,但如果非要兼容IE8 可使用IE 特有的 方法 window.clipboardData.setDat ...
- 【.Net】C#实现多线程的方式:使用Parallel类
简介 在C#中实现多线程的另一个方式是使用Parallel类. 在.NET4中 ,另一个新增的抽象线程是Parallel类 .这个类定义了并行的for和foreach的 静态方法.在为 for和 f ...