题意:

有$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. xhtml三种元素类型

    xhtml三种元素类型:块级元素/内联元素/可变元素 块级元素:独占一行.可自定义自己的宽度和高度.作为其他元素的容器,可容纳其他内联元素和块级元素,喻做一个盒子.内联元素:始终以行内逐个显示.不能设 ...

  2. Spring Cloud(十一):Spring Cloud Zuul网关 Filter、熔断、重试、高可用的使用方式

    上篇文章主要介绍了Zuul网关使用模式,以及自动转发机制,但其实Zuul还有更多的应用场景,比如:鉴权.流量转发.请求统计等等,这些功能都可以使用Zuul来实现. Zuul的核心 Filter是Zuu ...

  3. NumPy事例练习

    因为排版问题直接把jupyter里的截图过来了:暂时就写了这么点小例子,建议在ipython notebook中做测试

  4. IOS AFNETWORKING POST

    IOS AFNETWORKING POST 请求 #pragma mark post 请求 // 获取 url 路劲,不带参数 NSString *requestUrl = [[url compone ...

  5. Shiro乱炖

    眼瞅着7月份又要浑浑噩噩的荒度过去了... 说好的计划呢?人的惰性真是无法治愈的伤痛啊 话说最近研究Shiro, Linux和JavaScript, 但结果不怎么如意:Shiro还停留在理解拦截器方面 ...

  6. 使用jquery datatables插件遇到fnReloadAjax的问题

    1 官网地址:http://www.datatables.net/ 2 基本参数介绍 http://blog.csdn.net/mickey_miki/article/details/8240477 ...

  7. Colly provides a clean interface to write any kind of crawler/scraper/spider

    Scraping Framework for Golang http://go-colly.org/ https://github.com/gocolly/colly package main imp ...

  8. go echo studygolang ___go_build_myT_go__1_.exe

    https://github.com/studygolang/studygolang [stat]; 用户在线数据存到哪里:redis -> 表示存入 redis,这样支持多机部署; onlin ...

  9. Android 监听返回键退出程序的两种实现

    1.Android 双击返回键退出程序 思路:用户按下返回键时设定一个定时器来监控是否2秒内实现了退出,如果用户没有接着按返回键,则清除第一次按返回键的效果,使程序还原到第一次按下返回键之前的状态.定 ...

  10. ADFS 2016 – Cannot add/update Relying Parties from the GUI from metadata files “Method not found”

    UPDATE: The following update is fixing this issue: Cumulative Update for Windows 10 Version 1607 and ...