poj 3941 expected allowance
来源:互联网 发布:mac 百度云太慢 编辑:程序博客网 时间:2024/05/23 12:16
在初始化上吃了亏。犯了兵家大忌。
#include<iostream>#include<stdio.h>#include<cstring>#include<math.h>#include<cmath>using namespace std;int dp[2][100000008];int main(){int n,m,x,sum,i,j,k;while(scanf("%d%d%d",&n,&m,&k)!=EOF){if(n==0&&m==0&&k==0)break;sum=n*m;for(i=0;i<=sum;i++){dp[0][i]=0;dp[1][i]=0;}for(i=1;i<=m;i++)dp[1][i]=1;for(i=2;i<=n;i++){for(j=0;j<=sum;j++)dp[i%2][j]=0;for(x=sum;x>=1;x--){for(j=1;j<=m&&j<x;j++)dp[i%2][x]=dp[i%2][x]+dp[1-i%2][x-j];}}double all;all=pow((double)m,(double)n);double ans=0.0;for(i=1;i<=k;i++)ans=ans+(double)dp[n%2][i];for(i=k+1;i<=sum;i++)ans=ans+(double)(i-k)*dp[n%2][i];printf("%.8lf\n",ans/all);}return 0;}
- poj 3941 expected allowance
- POJ Problem 3941 Expected Allowance
- HDU 2909 - Expected Allowance
- Allowance POJ
- POJ 3040 Allowance 贪心
- poj 3040 Allowance 贪心
- 贪心-poj-3040-Allowance
- poj 3040 Allowance(贪心)
- poj 3040 Allowance (贪心)
- POJ 3040 Allowance
- POJ 3040 Allowance
- POJ 3040Allowance
- Allowance - POJ 3040 贪心
- Allowance (poj 3040 贪心)
- POJ 3040 Allowance
- poj 3040 Allowance贪心
- POJ 3040 Allowance 贪心
- 【POJ 3040】Allowance
- Google 2013校招笔试题:用swap排序
- QT中怎么设置和使用进度条
- web_custom_request 函数
- Java中的值传递和引用传递
- 二叉树的先序、中序、后序遍历方法(递归与非递归方法)——《数据结构》
- poj 3941 expected allowance
- 黑马程序员——三、java基础之面向对象.part2(5)
- 傻瓜式IOS发布教程(一)iTunes Connect创建应用以及内购
- 我的vim配置
- 近几天的杂思
- OPENCV 常用函数
- Java中重载和覆盖的区别
- 机器学习_算法_Apriori
- java中JAVA_HOME、PATH及CLASSPATH解析