题目链接点这里

题意:

  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. 上海苹果维修点分享苹果电脑MACBOOK故障维修常见案例

    苹果的电子设备无论是外观和性能都是无与伦比的美丽,很多开发者都开始选用苹果电脑macbook.近年来苹果售后维修点来维修苹果电脑的用户也越来越多,我们上海苹果维修点就整理分享了一些苹果电脑MACBOO ...

  2. (一)Robot Framework安装

    准备工作: Python 2.7 (目前不能良好支持python3) pip 和 setuptools (Python 的套件管理程式,最新版的Python 2.7.16已包含) Robot Fram ...

  3. 十二.GUI

    tkinter模块(tkinter是一个跨平台的PythonGUI工具包): #Tkinter是一个跨平台的Python GUI工具包 import tkinter top=tkinter.Tk() ...

  4. POJ 2728 Desert King(最优比率生成树, 01分数规划)

    题意: 给定n个村子的坐标(x,y)和高度z, 求出修n-1条路连通所有村子, 并且让 修路花费/修路长度 最少的值 两个村子修一条路, 修路花费 = abs(高度差), 修路长度 = 欧氏距离 分析 ...

  5. flume介绍及应用

    版权声明:本文为yunshuxueyuan原创文章.如需转载请标明出处: http://www.cnblogs.com/sxt-zkys/QQ技术交流群:299142667 flume的概念 1.   ...

  6. VMware搭建Oracle 11g RAC测试环境 For Linux

    环境如下: Linux操作系统:Centos 6.5 64bit (这个版本的redhat 6内核等OS在安装grid最后执行root.sh时会出现crs-4124,是oracle11.2.0.1的b ...

  7. [luoguP1198][JSOI2008] 最大数(线段树 || 单调栈)

    题目传送门 1.线段树 线段树可以搞. 不过慢的要死1300+ms #include <cstdio> #include <iostream> using namespace ...

  8. 关于系统中使用多个PropertyPlaceholderConfigurer的配置

    多数的鲜为人知方法都是因为有着罕见的应用,就比如说Spring中PropertyPlaceholderConfigurer这个类,它是用来解析Java Properties属性文件值,并提供在spri ...

  9. P1194 买礼物 洛谷

    https://www.luogu.org/problem/show?pid=1194 题目描述 又到了一年一度的明明生日了,明明想要买B样东西,巧的是,这B样东西价格都是A元. 但是,商店老板说最近 ...

  10. hdu 4971

    记忆花搜索   dp #include <cstdio> #include <cstdlib> #include <cmath> #include <set& ...