题目链接

题意:

亮亮有N个有瑕疵的硬币,有瑕疵意味着抛一枚硬币正面向上的概率 不等于 反面向上的概率 也即概率不等于0.5。

现在亮亮一次抛N个硬币 , 恰好有K个硬币正面向上 ,接着他又想抛一次 , 问:出现正面向上的个数的期望

抛硬币这个随机实验满足二项分布,即X~B(p , N)

所以期望 E(X) = N * P

而正面向上的概率不定 , 则概率为r的期望为:

即:E[X] = N * E[r].

接下来对E[r]进行化简:

∵p~Be(K+1 , N-K+1)

代入原式得:E(x)=N * (K+1) / (N+2)

代码如下:

 #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include <iterator>
using namespace std;
#define MAXN 1000000
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define eps 1e-6
#define LL long long int main()
{
int n , k;
while(scanf("%d %d",&n,&k)!=EOF)
{
printf("%.3lf\n", n * (k + 1.0) / (n + 2.0));
}
return ;
}

Hust 1231 Coin的更多相关文章

  1. Lightoj 1231 - Coin Change (I) (裸裸的多重背包)

    题目链接: Lightoj  1231 - Coin Change (I) 题目描述: 就是有n种硬币,每种硬币有两个属性(价值,数目).问用给定的硬币组成K面值,有多少种方案? 解题思路: 赤果果的 ...

  2. LightOJ - 1231 - Coin Change (I)

    先上题目: 1231 - Coin Change (I)   PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit:  ...

  3. Light OJ Dynamic Programming

    免费做一样新 1004 - Monkey Banana Problem 号码塔 1005 - Rooks 排列 1013 - Love Calculator LCS变形 dp[i][j][k]对于第一 ...

  4. UVA 674 Coin Change(dp)

    UVA 674  Coin Change  解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730#problem/ ...

  5. [LeetCode] Coin Change 硬币找零

    You are given coins of different denominations and a total amount of money amount. Write a function ...

  6. 洛谷P2964 [USACO09NOV]硬币的游戏A Coin Game

    题目描述 Farmer John's cows like to play coin games so FJ has invented with a new two-player coin game c ...

  7. [luogu2964][USACO09NOV][硬币的游戏A Coin Game] (博弈+动态规划)

    题目描述 Farmer John's cows like to play coin games so FJ has invented with a new two-player coin game c ...

  8. LeetCode Coin Change

    原题链接在这里:https://leetcode.com/problems/coin-change/ 题目: You are given coins of different denomination ...

  9. HUST 1017 - Exact cover (Dancing Links 模板题)

    1017 - Exact cover 时间限制:15秒 内存限制:128兆 自定评测 5584 次提交 2975 次通过 题目描述 There is an N*M matrix with only 0 ...

随机推荐

  1. Sysinternals Suite实用程序工具包

    Sysinternals Suite是微软出品的一套集成数十个绿色软件的实用程序工具包.就在2014年1月29日(官方日期),迎来了2014新版本 AccessChk为了确保创建安全的环境,Windo ...

  2. Sending e-mail with Spring MVC---reference

    reference from:http://www.codejava.net/frameworks/spring/sending-e-mail-with-spring-mvc Table of con ...

  3. 5 Common Interview Mistakes that Could Cost You Your Dream Job (and How to Avoid Them)--ref

    There have been many articles on our site on software testing interviews. That is because, we, as IT ...

  4. win7家庭版升级旗舰版

    点“开始”——在“所有程序”点"Windows Anytime Update"——点“输入升级密钥”,然后就出现一个密钥框,输入一个旗舰版的密钥,确定就行了,10分钟左右就升级好了 ...

  5. XC应用系列作品(Android应用)

    XC系列应用,如真题园手机客户端1.1等应用已经分别在 360手机助手.腾讯应用宝.百度手机助手.小米应用商店.豌豆荚.应用汇.木蚂蚁等安卓市场平台上线了! 本页面的系列应用是本人的开发的一Andro ...

  6. Java基础知识强化之IO流笔记24:FileInputStream / FileOutputStream 复制文本文件案例2

    1. 需求:把d盘下的a.txt的内容复制到f盘下的b.txt中: 代码示例: package com.himi.filecopy; import java.io.FileInputStream; i ...

  7. linux mysql 授权以及 iptables开启3306

    mysql授权ip段访问mysql grant all privileges on *.* to 'yang'@'192.168.1.%' identified by '123456'; linux ...

  8. System Operations on AWS - Lab 5W - Managing Resources (Windows)

    登陆到CommandHost实例,通过AWS CLI来管理各个资源 1. 通过Tags来管理资源 1.1 登陆到CommandHost实例 1.2 找出development实例 1.2.1 打开Po ...

  9. bash登录式shell(完全切换)与非登陆式shell(不完全切换)区别

    1.以登录式shell切换用户 su - username 登录式shell读取配置文件及其顺序: /etc/profile /etc/profile.d/*.sh ~/.bash_profile ~ ...

  10. angularJs 使用中遇到的问题小结【一:关于传参】

    我请教个问题 :我在界面传了一个参数<a ng-click="deleteOrder({{orderOrder}})" class="btn warning-btn ...