题目链接点这里

题意:

  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. 自定义ngCloak

    场景: 一个非常复杂的表单页面,页面有5个标签,第五个标签中又有5个标签,也就是说一共有9个标签,每个标签中都有一个表单,表单之间相互关联.所有表单项(包括复合的),有80多个数据.全部东西写在一个h ...

  2. exports和moudle. exports

    http://zihua.li/2012/03/use-module-exports-or-exports-in-node/ https://github.com/seajs/seajs/issues ...

  3. CodeForces 22、23部分题解

    CodeForces 22A 找严格第二小的...注意只有一种情况,可以sort排序然后unique输出. int a[N]; int main() { int n; while(~scanf(&qu ...

  4. Codeforces 892 B.Wrath

    B. Wrath time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...

  5. VirtualBox - 虚拟机下主机与虚拟机、虚拟机与虚拟机之间通信配置

    看了一下网上别人写的文章:http://www.it165.net/os/html/201401/7063.html 文章里面使用的是Debian,我这里配置的虚拟机系统一个是Ubuntu 14.10 ...

  6. SQLSERVER金额转换成英文大写的函数

    CREATE FUNCTION [dbo].[f_num_eng] (@num numeric(15,2)) RETURNS varchar(400) WITH ENCRYPTION AS BEGIN ...

  7. 【SPOJ694&705】Distinct Substrings(后缀数组)

    题意:求一个字符串的不相同的子串个数 n<=1000 思路:这是一道论文题 ..]of longint; n,i,m,ans,v,cas:longint; ch:ansistring; proc ...

  8. linux上配置spark集群

    环境: linux spark1.6.0 hadoop2.2.0 一.安装scala(每台机器)   1.下载scala-2.11.0.tgz   放在目录: /opt下,tar -zxvf scal ...

  9. php的错误控制运算符

    php的错误控制运算符 PHP中提供了一个错误控制运算符“@”. 可以将@放置在一个PHP表达式之前,该表达式可能产生的任何错误信息都被忽略掉: 如果开启了php.ini 中的 track_error ...

  10. java 基础 1 final关键字

    1. final关键字 数据:声明数据为常量,对于基本类型final使数值不变,对于引用类型final使引用不变,但引用所指向的值是可以改变的,例如       final StringBuffer ...