集训第六周 古典概型 期望 C题
http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=30728
一个立体方块,每个单位方块都是关闭状态,每次任两个点,以这两点为对角线的一个立方体状态都会进行一次转变,(开变成关,关变成开)
如此进行k次后,问开着的灯的期望值
思路:枚举所有的X,Y,Z,此灯被选中的概率为p=((2*(N-x+1)*x-1)*(2*(M-y+1)*y-1)*(2*(Z-z+1)*z-1))/(N*N*M*M*Z*Z)
这一点最后开着的期望值为(1-(1-2*p)^2)/2
最后累加期望值即可
#include"iostream"
#include"cstdio"
#include"cstring"
#include"cmath"
#include"algorithm"
using namespace std; int n,m,p,k,ca;
double ans; void Init()
{
scanf("%d%d%d%d",&n,&m,&p,&k);
} void Work()
{
int x,y,z;
ans=;
for(x=;x<=n;x++)
{
for(y=;y<=m;y++)
{
for(z=;z<=p;z++)
{
double P=((2.0*(n-x+)*x-)*(2.0*(m-y+)*y-)*(2.0*(p-z+)*z-))/(double(n)*n*m*m*p*p); ans+=(1.0-pow((1.0-*P),k))/;
}
}
}
} void Print()
{
printf("Case %d: %.10f\n",ca++,ans);
} int main()
{
int T;
cin>>T;
ca=;
while(T--)
{
Init();
Work();
Print();
}
return ;
}
集训第六周 古典概型 期望 C题的更多相关文章
- 集训第六周 古典概型 期望 D题 Discovering Gold 期望
Description You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell o ...
- 集训第六周 数学概念与方法 J题 数论,质因数分解
Description Tomorrow is contest day, Are you all ready? We have been training for 45 days, and all g ...
- 集训第六周 数学概念与方法 UVA 11722 几何概型
---恢复内容开始--- http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=31471 题意,两辆火车,分别会在[t1,t2],[ ...
- CF Gym 100187B A Lot of Joy (古典概型)
题意:给两个一样的只含有26个小写字母的字符串,然后两个分别做一下排列,问如果对应位置的字母相等那么就愉悦值就加一,问愉悦值的期望是多少? 题解:只考虑两个序列相对的位置,那么就相当于固定一个位置,另 ...
- 集训第六周 E题
E - 期望(经典问题) Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit S ...
- python数学第四天【古典概型】
- 集训第六周 O题
Description Gerald got a very curious hexagon for his birthday. The boy found out that all the angle ...
- 集训第六周 M题
Description During the early stages of the Manhattan Project, the dangers of the new radioctive ma ...
- 集训第六周 矩阵快速幂 K题
Description In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. F ...
随机推荐
- SQL 初级教程学习(二)
1.SQL 语句从 "Websites" 表中选取头两条记录: SELECT * FROM Websites LIMIT 2; SELECT TOP 50 PERCENT * FR ...
- 题解报告:hdu 2062 Subset sequence
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2062 Problem Description 考虑集合An = {1,2,...,n}. 例如,A1 ...
- Selenium2工作原理
Selenium 经历了两个版本,Selenium 1.0 和 Selenium 2.0,本文仅介绍Selenium2的原理,在Selenium 2.0 主推的是WebDriver,Selenium2 ...
- 442 Find All Duplicates in an Array 数组中重复的数据
给定一个整数数组 a,其中1 ≤ a[i] ≤ n (n为数组长度), 其中有些元素出现两次而其他元素出现一次.找到所有出现两次的元素.你可以不用到任何额外空间并在O(n)时间复杂度内解决这个问题吗? ...
- [转]windows azure How to use Blob storage from .NET
本文转自:http://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/?rnd=1 ...
- CSS ul li a 背景图片与文字对齐
<div class="four"> <h2>电子商务</h2> <img src="images/photo2.gif&quo ...
- LN : leetcode 413 Arithmetic Slices
lc 413 Arithmetic Slices 413 Arithmetic Slices A sequence of number is called arithmetic if it consi ...
- ES6学习笔记(2)----变量的解构和赋值
参考书<ECMAScript 6入门>http://es6.ruanyifeng.com/ 变量的解构和赋值 本质上:只要模式匹配,左边的变量就能被赋予右边对应的值 原则: 解构赋值的规则 ...
- 数据库时间类型是 datetime 类型的处理
当数据库时间类型是datetime类型时,获取前台时间是要这样处理 ,因为数据库是把时间转换为字符类型来比较的 sb.Append(" and Date <=convert(varch ...
- 如何向妻子解释OOD (转)
此文译自CodeProject上<How I explained OOD to my wife>一文,该文章在Top Articles上排名第3,读了之后觉得非常好,就翻译出来,供不 ...