poj 2151 01背包
来源:互联网 发布:中国gdp数据折线图 编辑:程序博客网 时间:2024/06/05 05:05
在别人列出的题目里面这道题是被归类到hash里面的,然而没有想到如何转化成hash搜索
这道题就是求出 Π每队至少解出一道题= Π(1-每队解出0道题的概率)=P1, Π每队解出不多于n道题的概率 =P2
注意的是P2 不包括解出0道的概率
#include<iostream> #include<vector>#include <string> #include<algorithm> #include<fstream>#include<cmath> using namespace std; #define lch(i) ((i)<<1) #define rch(i) ((i)<<1|1) #define sqr(i) ((i)*(i)) #define pii pair<int,int> #define mp make_pair #define FOR(i,b,e) for(int i=b;i<=e;i++) #define FORE(i,b,e) for(int i=b;i>=e;i--) #define ms(a) memset(a,0,sizeof(a)) const int maxnum =20010;const int key = 177;int tol,n,t,m,newn;double dp[1005];int main() { /*fstream fin("G:/1.txt");*/while (scanf("%d%d%d", &m, &t, &n), n | t | m){/*fin>>m>>t>>n;*/double one=1.0,below=1.0;double tmp;FOR(i,1,t){ms(dp);dp[0]=1;FOR(j,1,m){/*fin>>tmp;*/scanf("%lf",&tmp);FORE(k,t,1){dp[k]=dp[k]*(1-tmp)+dp[k-1]*tmp;}dp[0]=dp[0]*(1-tmp);}one*=1-dp[0];double sum=0;FOR(j,1,n-1){sum+=dp[j]; }below*=sum;}printf("%.3f\n",one-below);}return 0;}
0 0
- poj 2151 01背包
- poj 1837 01背包
- 01 背包 poj 3624
- poj-3211-01背包
- poj 3624 01背包
- poj 3628 01背包
- poj 3211 01 背包
- poj 1837 01背包
- poj 3093 01背包
- poj 3624 01 背包
- poj 3628 01背包
- poj 3628 01 背包
- poj 3624 01背包
- poj 3624 01背包
- POJ 3624 01背包
- POJ-3624 01背包
- poj 1976 01背包
- poj 3624(01背包)
- jQuery.extend 函数详解
- json 文件转换成 模型数据
- HDOJ 1950 Bridging signals(LIS nlogn)
- 两道面试题:2012年10月9号阿里巴巴笔试
- hdoj 1034 Candy Sharing Game【基础题】&&【关键是理解题意】
- poj 2151 01背包
- 如何在 Django 中使用 django-south, 实现数据迁移 (data migrations)
- 49. PHP 页面静态化(2)
- grep命令详解
- document.body.clientHeight = 0 ??
- 05 代码片格式化
- HTML编程图像处理
- HDOJ 4704 Sum(费马小定理+快速幂)
- 流式大数据处理的三种框架:Storm,Spark和Samza