题意:

有$n$个无中生有,有$m$个不同的杀,第$i$个杀掉$X_i$滴血,敌人血量$P$,求问第一回合就将敌人杀死的概率是多少。

解法:

二进制枚举$A$类,$B$类卡的顺序,这样就确定了取了几个$B$卡,dp即可

$f(i,j)$表示选了$i$个卡,伤害和为$j$的方案数。

$ans = \sum {f(j,P)j!(m-j)!}$

总效率$O(n 2^{n+m})$

认真读题。

#include <iostream>
#include <cstdio>
#include <cstring> #define LL unsigned long long
#define N 23
#define bit(x) (1<<(x)) using namespace std; int P, n, m;
int X[N];
LL f[N][N][], comb[N][N], fac[N]; LL gcd(LL a, LL b) {
if (b == ) return a;
return gcd(b, a % b);
} int main() {
comb[][] = ;
fac[] = ;
for (int i = ; i <= ; i++) {
fac[i] = fac[i-] * i;
comb[i][] = ;
for (int j = ; j <= i; j++)
comb[i][j] = comb[i-][j-] + comb[i-][j];
}
int T;
scanf("%d", &T);
while (T--)
{
memset(f, , sizeof(f));
scanf("%d %d %d", &P, &n, &m);
X[] = ;
for(int i = ; i <= m; i++) scanf("%d", &X[i]);
f[][][] = ;
for(int i = ; i < m; i++)
for(int j = ; j <= i; j++)
for(int k = P; k >= ; k--)
{
f[i+][j][k] += f[i][j][k];
f[i+][j+][min(k+X[i+],P)] += f[i][j][k];
}
LL ans0 = , ans1 = ;
for(int S=;S<(<<(n+m));S++)
{
int cnt=,i,j=;
for(i=;i<n+m;i++) if(bit(i)&S) cnt++;
if(cnt!=m) continue;
ans1 += fac[m];
cnt=;
for(i=;i<n+m && cnt;i++)
{
if(bit(i)&S) cnt--, j++;
else cnt++;
}
ans0 += f[m][j][P] * fac[m-j] * fac[j];
}
if(ans0 == ) {
puts("0/1");
continue;
}
LL d = gcd(ans0, ans1);
cout << ans0/d << '/' << ans1/d << endl;
}
return ;
}

Hearthstone的更多相关文章

  1. HDU 5816 Hearthstone

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Descript ...

  2. HDU5816 Hearthstone(状压DP)

    题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5816 Description Hearthstone is an online collec ...

  3. 多校7 HDU5816 Hearthstone 状压DP+全排列

    多校7 HDU5816 Hearthstone 状压DP+全排列 题意:boss的PH为p,n张A牌,m张B牌.抽取一张牌,能胜利的概率是多少? 如果抽到的是A牌,当剩余牌的数目不少于2张,再从剩余牌 ...

  4. HDU 5816 Hearthstone (状压DP)

    Hearthstone 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5816 Description Hearthstone is an onlin ...

  5. HDU5816 Hearthstone

    Hearthstone                                                                        Time Limit: 2000/ ...

  6. HDU 5816 Hearthstone 概率dp

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5816 Hearthstone Time Limit: 2000/1000 MS (Java/Othe ...

  7. hdu-5816 Hearthstone(状压dp+概率期望)

    题目链接: Hearthstone Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Other ...

  8. Google Deepmind AI tries it hand at creating Hearthstone and Magic: The Gathering cards

    http://www.techrepublic.com/article/google-deepmind-ai-tries-it-hand-at-creating-hearthstone-magic-t ...

  9. Programming a Hearthstone agent using Monte Carlo Tree Search(chapter one)

    Markus Heikki AnderssonHåkon HelgesenHesselberg Master of Science in Computer Science Submission dat ...

  10. How to appraise Hearthstone card values

    https://elie.net/blog/hearthstone/how-to-appraise-hearthstone-card-values/ In 2014, I became an avid ...

随机推荐

  1. C++获取站点的ip地址

     #include "stdafx.h" #include <winsock2.h> #pragma comment (lib,"ws2_32.lib&q ...

  2. 重温.NET下Assembly的加载过程 ASP.NET Core Web API下事件驱动型架构的实现(三):基于RabbitMQ的事件总线

    重温.NET下Assembly的加载过程   最近在工作中牵涉到了.NET下的一个古老的问题:Assembly的加载过程.虽然网上有很多文章介绍这部分内容,很多文章也是很久以前就已经出现了,但阅读之后 ...

  3. python 写数据到txt 文件

    # coding=utf-8 import codecs # list = [[1,2],[3,4]] list = ['{"PN":"34VT123",&qu ...

  4. D3js-API介绍【英】

    Everything in D3 is scoped under the d3 namespace. D3 uses semantic versioning. You can find the cur ...

  5. 对canvas arc()中counterclockwise参数的一些误解

    一直没有很细心地去研究CanvasRenderingContext2D对象的arc方法,对它的认识比较模糊,导致犯了一些错误,特发此文,以纠正之前的错误理解. arc()方法定义如下: arc() 方 ...

  6. RESTful API 设计原则

    http://www.ruanyifeng.com/blog/2014/05/restful_api.html http://www.ruanyifeng.com/blog/2011/09/restf ...

  7. Selenium学习(一)环境搭建

    一.安装selenium有两种方式: 1.pip install -U selenium(网络条件好) 2.下载selenium安装包,通过python setup.py install(压缩包)或p ...

  8. switch中的case不加break执行情况

    输出结果:230 分析,switch先匹配一个case满足$a,然后执行case里面的语句,直到遇到break,否则一直往下执行 <?php $a = ; switch($a){ : echo ...

  9. eclipse中run as无run as server选项的解决方案

    在项目->右击->Properties->Project Facets->Modify Project,选择Java和DynamicWeb Module

  10. Redis 过期键的设置、获取和删除过期时间

    Redis 过期键的设置.获取和删除过期时间 转自http://blog.51cto.com/littledevil/1813956 设置过期 默认情况下键是没有生存时间的,也就是永不过期,除非清空内 ...