[概率dp 矩阵乘法] poj 3744 Scout YYF I
来源:互联网 发布:小米手环数据修改攻略 编辑:程序博客网 时间:2024/03/29 05:51
题目分析
占坑
代码
#include <cstdio>#include<iostream>#include<cmath>#include<cstring>#include<string>#include<algorithm>#include<map>using namespace std;const int maxr=100000000+5;const int maxn=12;struct mat{ double e[2][2]; mat(){e[0][0]=e[1][1]=1,e[0][1]=e[1][0]=0;} mat& operator*(mat& x) { mat ans= *this; for(int i=0;i<=1;i++) for(int j=0;j<=1;j++) ans.e[i][j]=e[i][0]*x.e[0][j]+e[i][1]*x.e[1][j]; return ans; }};double qpow(mat a,int p){ mat ans; for(;p;p>>=1) { if(p&1) ans = ans*a; a=a*a; } return ans.e[0][0];}int n;double p;long long a[maxn];mat M;int main(){ while(cin>>n>>p) { M.e[0][0]=p,M.e[0][1]=1-p,M.e[1][0]=1,M.e[1][1]=0; a[0]=0; for(int i=1;i<=n;i++) scanf("%d",&a[i]); sort(a+1,a+n+1); n=unique(a+1,a+n+1)-a-1; double ans=1; for(int i=1;i<=n;i++) ans=ans*(1-qpow(M,a[i]-a[i-1]-1)); printf("%.7f\n",ans); } return 0;}
0 0
- poj 3744 Scout YYF I 概率dp+矩阵乘法
- [概率dp 矩阵乘法] poj 3744 Scout YYF I
- poj 3744 Scout YYF I (矩阵乘法+概率与期望DP)
- poj 3744 Scout YYF I(概率DP&矩阵快速幂)
- poj 3744 Scout YYF I(概率dp+矩阵快速幂)
- POJ 3744 Scout YYF I 概率DP + 矩阵快速幂
- poj 3744 Scout YYF I(概率dp+矩阵快速幂)
- Poj 3744 Scout YYF I (概率DP 矩阵优化)
- poj 3744 Scout YYF I(矩阵优化概率DP)
- POJ 3744 Scout YYF I 概率dp+矩阵快速幂
- POJ 3744 Scout YYF I 概率dp 矩阵快速幂
- Poj 3744 Scout YYF I(矩阵概率DP)
- POJ 3744 Scout YYF I (概率DP+矩阵快速幂)
- 【POJ】3744 Scout YYF I (概率DP+矩阵优化)
- POJ 3744 Scout YYF I (概率dp+矩阵优化)
- POJ 3744 Scout YYF I 概率dp+矩阵加速
- POJ 3744Scout YYF I 概率DP+矩阵优化
- POJ 3744 Scout YYF I (矩阵相乘+概率DP)
- java-面试-阿里
- POJ3468(线段树成段增加)
- hdu 5730(分治FFT)
- poj3278 Catch That Cow
- POJ 1258Agri-Net
- [概率dp 矩阵乘法] poj 3744 Scout YYF I
- java-学习-自我规划
- 枚举+求桥 Codeforces701F Break Up
- POJ1995 Raising Modulo Numbers
- Codeforces Round #364 (Div. 2)E.Connecting Universities
- HDU 1052 Tian Ji -- The Horse Racing
- 重构
- mysql cluster (mysql 集群)安装配置方案
- 浅谈Java的final关键字