HDU5816 Hearthstone
Hearthstone
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1110 Accepted Submission(s): 548
card to solve this dilemma. We call this "Shen Chou Gou" in Chinese.

Now you are asked to calculate the probability to become a "Shen Chou Gou" to kill your enemy in this turn. To simplify this problem, we assume that there are only two kinds of cards, and you don't need to consider the cost of the cards.
-A-Card: If the card deck contains less than two cards, draw all the cards from the card deck; otherwise, draw two cards from the top of the card deck.
-B-Card: Deal X damage to your enemy.
Note that different B-Cards may have different X values.
At the beginning, you have no cards in your hands. Your enemy has P Hit Points (HP). The card deck has N A-Cards and M B-Cards. The card deck has been shuffled randomly. At the beginning of your turn, you draw a card from the top of the card deck. You can use
all the cards in your hands until you run out of it. Your task is to calculate the probability that you can win in this turn, i.e., can deal at least P damage to your enemy.
Then come three positive integers P (P<=1000), N and M (N+M<=20), representing the enemy’s HP, the number of A-Cards and the number of B-Cards in the card deck, respectively. Next line come M integers representing X (0<X<=1000) values for the B-Cards.
3 1 2
1 2
3 5 10
1 1 1 1 1 1 1 1 1 1
46/273
牌堆有n张奥术智慧,奥术智慧可以再从牌堆摸两张牌, m张伤害牌,伤害各为xi,初始从牌堆摸一张,问本回合能击杀给定hp的对手的概率,结果用分数表示。(n+m<=20)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <vector>
#include <bitset> using namespace std; #define LL long long
const int INF = 0x3f3f3f3f;
#define MAXN 500 LL dp[1<<21];
LL f[22];
int d[20];
LL gcd(LL x,LL y)
{
return x?gcd(y%x,x):y;
} int main()
{
f[0]=1;
for(int i=1; i<21; i++)
f[i]=f[i-1]*i; int T,m,n,p;
for(scanf("%d",&T); T--;)
{
scanf("%d%d%d",&p,&n,&m);
for(int i=0; i<m; i++)
scanf("%d",&d[i]);
int N=m+n;
memset(dp,0,sizeof dp);
dp[0]=1;
for(int x=0; x<(1<<N); x++)
{
int a=0,b=0,k=0;
for(int i=0; i<m; i++)
{
if(x&(1<<i))
{
k+=d[i];
b++;
}
}
if(k>=p) continue;//伤害够了不抽了
for(int i=m; i<N; i++)
{
if(x&(1<<i))
{
a++;
}
}
if(a-b+1<=0) continue;//牌不能再抽了 for(int i=0;i<N;i++)
{
if(x&(1<<i)) continue;
dp[x^(1<<i)]+=dp[x];//在抽一张的状态数加上现在的状态
}
}
LL ans=0;
for(int x=0;x<(1<<N);x++)
{
if(dp[x]==0) continue;
int a=0,b=0,k=0;
for(int i=0; i<m; i++)
{
if(x&(1<<i))
{
k+=d[i];
b++;
}
}
if(k<p) continue;
for(int i=m; i<N; i++)
{
if(x&(1<<i))
{
a++;
}
}
if(a-b+1<0) continue;
ans+=dp[x]*f[N-a-b];
}
printf("%lld/%lld\n",ans/gcd(ans,f[N]),f[N]/gcd(ans,f[N]));
}
return 0;
}
HDU5816 Hearthstone的更多相关文章
- 多校7 HDU5816 Hearthstone 状压DP+全排列
多校7 HDU5816 Hearthstone 状压DP+全排列 题意:boss的PH为p,n张A牌,m张B牌.抽取一张牌,能胜利的概率是多少? 如果抽到的是A牌,当剩余牌的数目不少于2张,再从剩余牌 ...
- HDU5816 Hearthstone(状压DP)
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5816 Description Hearthstone is an online collec ...
- hdu-5816 Hearthstone(状压dp+概率期望)
题目链接: Hearthstone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- HDU 5816 Hearthstone
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Descript ...
- HDU 5816 Hearthstone (状压DP)
Hearthstone 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5816 Description Hearthstone is an onlin ...
- HDU 5816 Hearthstone 概率dp
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5816 Hearthstone Time Limit: 2000/1000 MS (Java/Othe ...
- 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 ...
- Programming a Hearthstone agent using Monte Carlo Tree Search(chapter one)
Markus Heikki AnderssonHåkon HelgesenHesselberg Master of Science in Computer Science Submission dat ...
- How to appraise Hearthstone card values
https://elie.net/blog/hearthstone/how-to-appraise-hearthstone-card-values/ In 2014, I became an avid ...
随机推荐
- 定点CORDIC算法求所有三角函数及向量模的原理分析、硬件实现(FPGA)
一.CORDIC算法 CORDIC(Coordinate Rotation DIgital Computer)是一种通过迭代对多种数学函数求值的方法,它可以对三角函数.双曲函数和平面旋转问题进行求解. ...
- c# webBrowser 转图片
class NativeMethods { [ComImport] [Guid("0000010D-0000-0000-C000-000000000046")] [Interfac ...
- ERROR: 9-patch image C:\...\res\drawable\appwidget.9.png malformed. Frame pixels must be either solid or transparent (not intermediate alphas).
this is the problem with latest adt that is 20.0.3. you can instead rename the *.9.png to *.png and ...
- select2的设置选中
select2插件设置选中值并显示的问题 在select2中,要想设置指定值为选中状态并显示: $("#select2_Id").val("XXXXX").se ...
- redis哨兵集群
Sentinel 哨兵 修改src下的sentinel.conf文件 , 配置端口 :port:随便 daemonize yes 配置主服务器的ip 和端口 我们把监听的端口修改成7000,并且 ...
- es6对象的扩展
对象(object)是 JavaScript 最重要的数据结构之一. object 在es6中新增了很多便利的方法 在es6中允许直接写入变量和方法的名称直接作为对象的属性 let x =1 ,y=2 ...
- 52-2018 蓝桥杯省赛 B 组模拟赛(一)java
最近蒜头君喜欢上了U型数字,所谓U型数字,就是这个数字的每一位先严格单调递减,后严格单调递增.比如 212212 就是一个U型数字,但是 333333, 9898, 567567, 313133131 ...
- 使用JFlex生成词法分析器 1:安装配置
环境:Windows 10 STEP 1: 下载 JFlex 文件,我选择的是 jflex-1.7.0.zip.下载完成后解压到想安装的位置. 文件结构如下(假设解压目录为 C:\): C:\jfle ...
- jenkins远程执行脚本时报Bad version number in .class file
这几天在学习jenkins的持续集成和部署,到了最后一步启动服务的时候,遇到了一个这个Bad version number in .class file的报错(如下图). 这个报错在最开始手工部署的时 ...
- Google资深工程师深度讲解Go语言完整教程
资源获取链接点击这里 欢迎大家来到深度讲解Go语言的课堂.本课程将从基本语法讲起,逐渐深入,帮助同学深度理解Go语言面向接口,函数式编程,错误处理,测试,并行计算等元素,并带领大家实现一个分布式爬虫的 ...