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 ...
随机推荐
- 聊聊Android5.0中的水波纹效果
水波纹效果已经不是什么稀罕的东西了,用过5.0新控件的小伙伴都知道这个效果,可是如果使用一个TextView或者Button或者其它普通控件的话,你是否知道如何给它设置水波纹效果呢?OK,我们今天就来 ...
- C++学习(一)
一.C++语言语法基础(6)1.从C到C++的过渡(1)2.类和对象(2)剑3.操作符重载(1)4.继承与多态(1)5.异常和I/O流(1)二.数据结构和算法(3)1.基本数据结构,堆栈.队列.链表. ...
- 阿里云ECS被攻击
今天发现阿里云ECS被攻击了,记录一下, /1.1 Match1:{ :;};/usr/bin/perl -e 'print .content-type: text/plain.r.n.r.nxsuc ...
- 20151221jquery学习笔记--验证插件
验证插件(validate.js),是一款验证常规表单数据合法性的插件.使用它,极大的解放了在表单上繁杂的验证过程,并且错误提示显示的完善也增加了用户体验.一. 使用 validate.js 插件官网 ...
- 向SQL2008R2导入Acess、excel数据
一:导入Access数据 1.在sql2008查询分析 器中输入如下查询语句能查出access中的数据 SELECT * FROM OpenDataSource( 'Microsoft.Jet.OLE ...
- C#下如何用NPlot绘制期货股票K线图(2):读取数据文件让K线图自动更新
[内容介绍]上一篇介绍了K线图的基本绘制方法,但很不完善,本篇增加了它直接读取数据的功能,这对于金融市场的数据量大且又需要动态刷新功能的实现很重要. [实现方法] 1.需要一个数据文件,这里用的是直接 ...
- Oracle 10g 默认安装带来的用户名/密码
ORACLE数据库创建的时候,创建了一系列默认的用户和表空间 Oracle 10g 默认安装带来的用户名/密码 Username Password Description See Also CTXSY ...
- Erlang官方站点
YOUR ERLANG COMMUNITY SITE Welcome to erlangcentral.org, the Erlang community site where you can rea ...
- Hdu 4514 湫湫系列故事——设计风景线
湫湫系列故事--设计风景线 Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total ...
- Codevs 3990 中国余数定理 2
3990 中国余数定理 2 时间限制: 1 s 空间限制: 1000 KB 题目等级 : 白银 Silver 传送门 题目描述 Description Skytree神犇最近在研究中国博大精深的数学. ...