题目链接点这里

题意:

  1~N标号的球

  现在A有C个,B有C个

  每次可以随机得到D个不同的球(1~N);问你A或B中的C个球都出现一次的 期望次数

题解:

  dp[i][j][k]表示 随机出现了i个仅仅属于A的球的个数,仅仅属于B的球的个数,同时属于A,B的球的个数

#include<bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
#define ls i<<1
#define rs ls | 1
#define mid ((ll+rr)>>1)
#define pii pair<int,int>
#define MP make_pair
typedef long long LL;
const long long INF = 1e18+1LL;
const double Pi = acos(-1.0);
const int N = 1e5+, M = 1e3+, mod = 1e9+, inf = 2e9; LL Con[][];
double dp[][][];
int vis[][][],cnt[],n,d,C,id[];
double dfs(int i,int j,int k) {
if(vis[i][j][k]) return dp[i][j][k];
double& ret = dp[i][j][k];
vis[i][j][k] = ;
if(i + k >= C || j + k >= C) return ret = ;
double tmp = ;
double xx;
for(int a = ; a + i <= cnt[]; ++a) {
for(int b = ; b + j <= cnt[]; ++b) {
for(int c = ; c + k <= cnt[]; ++c) {
if(a+b+c > d) continue;
double p = 1.0*Con[cnt[]-i][a] *
Con[cnt[]-j][b] * Con[cnt[]-k][c] *
Con[n-cnt[]-cnt[]-cnt[]+i+j+k][d-a-b-c]/Con[n][d]*1.0;
if(a+b+c==) {
xx = p;
}
else
{
tmp += p*dfs(i+a,j+b,k+c);
}
}
}
}
ret = tmp/(-xx);
return ret;
}
int main()
{
for(int i = ; i <= ; ++i) {
Con[i][] = ,Con[i][i] = ;
for(int j = ; j < i; ++j)
Con[i][j] = Con[i-][j] + Con[i-][j-];
}
scanf("%d%d%d",&n,&d,&C);
for(int i = ; i < ; ++i) {
for(int j = ; j <= C; ++j) {
int x;
scanf("%d",&x);
id[x] |= (<<i);
}
}
for(int i = ; i <= n; ++i) if(id[i]) cnt[id[i]]++;
printf("%.12f\n",dfs(,,));
return ;
} /*
2 1 1
1 2 30 5 10
2 3 5 7 11 13 17 19 23 29
20 18 16 14 12 10 8 6 4 2
*/

2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016) D.Dinner Bet 概率DP+排列组合的更多相关文章

  1. Gym 2009-2010 ACM ICPC Southwestern European Regional Programming Contest (SWERC 2009) A. Trick or Treat (三分)

    题意:在二维坐标轴上给你一堆点,在x轴上找一个点,使得该点到其他点的最大距离最小. 题解:随便找几个点画个图,不难发现,答案具有凹凸性,有极小值,所以我们直接三分来找即可. 代码: int n; lo ...

  2. 2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016) F dfs序+树状数组

    Performance ReviewEmployee performance reviews are a necessary evil in any company. In a performance ...

  3. 2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016)

    A. Within Arm's Reach 留坑. B. Bribing Eve 枚举经过$1$号点的所有直线,统计直线右侧的点数,旋转卡壳即可. 时间复杂度$O(n\log n)$. #includ ...

  4. 2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016) B - Bribing Eve

    地址:http://codeforces.com/gym/101174/attachments 题目:pdf,略 思路: 把每个人的(x1,x2)抽象成点(xi,yi). 当1号比i号排名高时有==& ...

  5. 2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016) E.Passwords AC自动机+dp

    题目链接:点这里 题意: 让你构造一个长度范围在[A,B]之间 字符串(大小写字母,数字),问你有多少种方案 需要满足条件一下: 1:构成串中至少包含一个数字,一个大写字母,一个小写字母:   2:不 ...

  6. 2017-2018 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2017)

    A. Cakey McCakeFace 按题意模拟即可. #include<stdio.h> #include<iostream> #include<string.h&g ...

  7. 2016-2017 ACM-ICPC Northwestern European Regional Programming Contest (NWERC 2016)

    A. Arranging Hat $f[i][j]$表示保证前$i$个数字有序,修改了$j$次时第$i$个数字的最小值. 时间复杂度$O(n^3m)$. #include <bits/stdc+ ...

  8. 2016-2017 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2016)

    题目链接  Codefores_Gym_101164 Solved  6/11 Penalty Problem A Problem B Problem C Problem D Problem E Pr ...

  9. 2017-2018 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2017)

    2017-2018 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2017) 全靠 wxh的博客 补完这套.wx ...

随机推荐

  1. vue项目中设置跨域

    config->index.js 'use strict' // Template version: 1.3.1 // see http://vuejs-templates.github.io/ ...

  2. 【BZOJ 1084】 [SCOI2005]最大子矩阵(DP)

    题链 http://www.lydsy.com/JudgeOnline/problem.php?id=1084 Description 这里有一个n*m的矩阵,请你选出其中k个子矩阵,使得这个k个子矩 ...

  3. 数据结构实验1:C++实现静态顺序表类

    写了3个多小时,还是太慢了.太菜了! 图1 程序运行演示截图1 实验1 1.1 实验目的 熟练掌握线性表的顺序存储结构. 熟练掌握顺序表的有关算法设计. 根据具体问题的需要,设计出合理的表示数据的顺序 ...

  4. NOI模拟赛(3.15) sequence(序列)

    Description 小A有N个正整数,紧接着,他打算依次在黑板上写下这N个数.对于每一个数,他可以决定将这个数写在当前数列的最左边或最右边.现在他想知道,他写下的数列的可能的最长严格上升子序列(可 ...

  5. Java学习之理解递归

    Java支持递归.递归是根据自身定义内容的过程.就Java编程而言,递归是一个允许方法调用自身的特性.调用自身的方法被称为递归.典型的例子就是阶乘的计算,N的阶乘就是从1到N之间所有整数的乘积. 当方 ...

  6. Nginx与python web服务配置(Uwsgi& FastCGI)

    Uwsgi start uswgi uwsgi --harakiri 360000 --body-read-warning=10000 --max-fd=65536 -b 1000000 --http ...

  7. 大数据学习——linux常用命令(三)

    三 文件操作 1创建文件 touch somefile.txt 创建一个空文件somefile.txt > 重定向操作符 echo "woshiwoa"> some.t ...

  8. [Go]GOPATH相关知识点

    在成功安装好Go之后,执行命令 go env 就可以看到有关go的一些环境变量,其中比较关键的是GOROOT.GOPATH和 GOBIN 1.设置GOPATH环境变量有什么意义? GOPATH是指:指 ...

  9. Centos6.5安装Oracle11.2.0.4 RAC(完整版)

    环境参数:Linux:Centos6.5 Grid和Oracle:11.2.0.4 一.环境配置 1.配置Node1和Node2两个节点之间的网卡 Node1: [root@rac1 network- ...

  10. Codeforces Round #292 (Div. 2) D. Drazil and Tiles [拓扑排序 dfs]

    传送门 D. Drazil and Tiles time limit per test 2 seconds memory limit per test 256 megabytes Drazil cre ...