LightOj_1317 Throwing Balls into the Baskets
题意:
有N个人, M个篮框, 每个人投进球的概率是P。
问每个人投K次后, 进球数的期望。
思路:
每个人都是相互独立的, 求出一个人进球数的期望即可。
进球数和篮框的选择貌似没有什么关系, 所以给的这个M并没有什么卵用。。。。
每个人进球数的期望为:E = sigma (i * C(K, i) * p ^ i * (1 - p) ^ (k - i));
总的进球数期望为:N * E
代码:
- #include <cmath>
- #include <cstdio>
- #include <cstring>
- #include <cstdlib>
- #include <ctime>
- #include <set>
- #include <map>
- #include <list>
- #include <queue>
- #include <string>
- #include <vector>
- #include <fstream>
- #include <iterator>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- #define LL long long
- #define INF 0x3f3f3f3f
- #define MOD 1000000007
- #define eps 1e-6
- #define MAXN 20
- #define MAXM 100
- #define dd cout<<"debug"<<endl
- #define p(x) printf("%d\n", x)
- #define pd(x) printf("%.7lf\n", x)
- #define k(x) printf("Case %d: ", ++x)
- #define s(x) scanf("%d", &x)
- #define sd(x) scanf("%lf", &x)
- #define mes(x, d) memset(x, d, sizeof(x))
- #define do(i, x) for(i = 0; i < x; i ++)
- int n, m, k;
- double p;
- double C[MAXN][MAXN];
- void init()
- {
- C[][] = ;
- for(int i = ; i < MAXN; i ++)
- {
- C[i][] = ;
- for(int j = ; j <= i; j ++)
- C[i][j] = C[i-][j] + C[i-][j-];
- }
- }
- double cal(int x)
- {
- double p_temp = 1.0;
- for(int i = ; i <= x; i ++)
- p_temp *= p;
- for(int j = ; j <= n - x; j ++)
- p_temp *= (1.0 - p);
- return x * C[n][x] * p_temp;
- }
- int main()
- {
- int T;
- int kcase = ;
- init();
- scanf("%d", &T);
- while(T --)
- {
- scanf("%d %d %d %lf", &n, &m, &k, &p);
- double ans = ;
- for(int i = ; i <= n; i ++)
- ans += cal(i);
- ans *= k;
- k(kcase), pd(ans);
- }
- return ;
- }
LightOj_1317 Throwing Balls into the Baskets的更多相关文章
- lightOJ 1317 Throwing Balls into the Baskets
lightOJ 1317 Throwing Balls into the Baskets(期望) 解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/ ...
- LightOJ - 1317 Throwing Balls into the Baskets 期望
题目大意:有N个人,M个篮框.K个回合,每一个回合每一个人能够投一颗球,每一个人的命中率都是同样的P.问K回合后,投中的球的期望数是多少 解题思路:由于每一个人的投篮都是一个独立的事件.互不影响.所以 ...
- Light OJ 1317 Throwing Balls into the Baskets 概率DP
n个人 m个篮子 每一轮每一个人能够选m个篮子中一个扔球 扔中的概率都是p 求k轮后全部篮子里面球数量的期望值 依据全期望公式 进行一轮球数量的期望值为dp[1]*1+dp[2]*2+...+dp[ ...
- KUANGBIN带你飞
KUANGBIN带你飞 全专题整理 https://www.cnblogs.com/slzk/articles/7402292.html 专题一 简单搜索 POJ 1321 棋盘问题 //201 ...
- [kuangbin带你飞]专题1-23题目清单总结
[kuangbin带你飞]专题1-23 专题一 简单搜索 POJ 1321 棋盘问题POJ 2251 Dungeon MasterPOJ 3278 Catch That CowPOJ 3279 Fli ...
- ACM--[kuangbin带你飞]--专题1-23
专题一 简单搜索 POJ 1321 棋盘问题POJ 2251 Dungeon MasterPOJ 3278 Catch That CowPOJ 3279 FliptilePOJ 1426 Find T ...
- LightOJ 1317 第八次比赛 A 题
Description You probably have played the game "Throwing Balls into the Basket". It is a si ...
- ACM第六周竞赛题目——A LightOJ 1317
A - A Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Status P ...
- LightOJ 1317 第六周比赛A题
A - A Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Description Y ...
随机推荐
- Java中字符流与字节流的区别
字符流处理的单元为2个字节的Unicode字符,分别操作字符.字符数组或字符串,而字节流处理单元为1个字节,操作字节和字节数组.所以字符流是由Java虚拟机将字节转化为2个字节的Unicode字符为单 ...
- RFC 2616
Network Working Group R. Fielding Request for Comments: 2616 UC Irvine Obsoletes: 2068 J. Gettys Cat ...
- Apache【第一篇】安装
一.简介 Apache HTTP Server(简称Apache)是Apache软件基金会的一个开放源码的网页服务器,可以在大多数计算机操作系统中运行,由于其多平台和安全性被广泛使用,是最流行的Web ...
- Bootstrap的竞争对手Zurb Foundation
Bootstrap并不是唯一的前端开发框架,比如还有JQuery UI.HTML5 Boilerplate等等.但对于Bootstrap来说,真正的竞争对手是Zurb Foundation.Boots ...
- 处理 eclipse 导入报错 Invalid project description,问题
有时候在添加工程时,会出现如图所示的错误信息, ,提示显示将要添加的工程已经存在,但是在工作空间里却找不到,这个时候,要做就是, 在导入的时候选择General->Existing Projec ...
- HDU-1034(简单模拟)
Candy Sharing Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- struts2学生信息管理系统篇章②进度报告篇章
之前做这个系统的时候是什么都不懂的! 经过一个月的时间,慢慢的java的知识都捡起来了. 对struts2和mvc模式都有一一定程度的了解,汇报一下上次的进度. 这个系统我所有的功能中我暂时只做到了下 ...
- 学习重点:1、金典的设计模式在实际中应用2、JVM原理3、jui源代码
学习重点:1.金典的设计模式在实际中应用 2.JVM原理 3.jui源代码
- Solr 1.3 安装步骤
可以通过以下三种方式之一设置 Solr 的主位置: 1.设置 java 系统属性 solr.solr.home (没错,就是 solr.solr.home). 2.配置 ...
- Spring Boot应用的健康监控
在之前的系列文章中我们学习了如何进行Spring Boot应用的功能开发,以及如何写单元测试.集成测试等,然而,在实际的软件开发中需要做的不仅如此:还包括对应用程序的监控和管理. 正如飞行员不喜欢盲目 ...