SGU 495 Kids and Prizes (概率DP入门)

原创 2015年07月09日 21:18:16

设dp[i] 为前i个winners获得pizza的期望。

状态转移方程: dp[i+1] = dp[i]*dp[i] / N + (dp[i] + 1)*(N - dp[i]) / N 。


代码:

#include<cstdio>
#include<iostream>

using namespace std;
const int maxm = 100005;

double dp[maxm];
int n,m;

int main(){
    scanf("%d%d",&n,&m);
    dp[0] = 0;
    for(int i=1;i<=m;i++){
        dp[i] = dp[i-1]*dp[i-1]/n + (dp[i-1]+1)*(n-dp[i-1])/n;
    }
    printf("%.9f\n",dp[m]);
    return 0;
}


版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

SGU 495 Kids and Prizes (概率DP)

Copied from kuangbin 495. Kids and Prizes Time limit per test: 0.5 second(s) Memory limit: ...

SGU 495 Kids and Prizes (概率DP)

495. Kids and Prizes Time limit per test: 0.5 second(s) Memory limit: 262144 kilobytes input: sta...

SGU-495 Kids and Prizes(概率DP)

最终期望是每个人拿到奖品的概率之和,考虑同时只存在一个人拿到盒子 第i个人拿到奖品的概率与前一个人拿到奖品的概率有关,所以设dp[i]表示第i个拿盒子的人拿到奖品的概率 则dp[i]可由两个状态转移而...

[ACM] SGU 495 Kids and Prizes (概率,期望,二项分布)

495. Kids and Prizes Time limit per test: 0.25 second(s) Memory limit: 262144 kilobytes inp...

SGU 495 Kids and Prizes(期望DP || 数学规律)

Kids and Prizes Description ICPC (International Cardboard Producing Company) is in the bus...

SGU 495 Kids and Prizes [期望]

ICPC (International Cardboard Producing Company) is in the business of producing cardboard boxes. —...

Kids and Prizes(概率+期望)

http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=113#problem/K 概率又还给老师了。。。 有n个奖品放在n个盒子里,...

概率dp sgu495

Kids and Prizes Time Limit:250MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Sub...

Kids and Prizes 来源: <http://acm.hust.edu.cn/vjudge/contest/view.action?cid=85996#problem/B>

B - Kids and Prizes Time Limit:250MS     Memory Limit:262144KB     64bit IO Format:%I64d &am...

Codeforces Round #384(Div. 2)D. Chloe and pleasant prizes【树形dp】

D. Chloe and pleasant prizes time limit per test 2 seconds memory limit per test 256 megabyt...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)