UVa 1637 - Double Patience(概率DP)】的更多相关文章

题意:36张扑克,平分成9摞,两张数字一样的可以拿走,每次随机拿两张,问能拿光的概率. 解法:记忆化搜索,状态压缩.一开始我想在还没拿的时候概率是1,然后往全拿光推···样例过不去···后来觉得推反了,改成了深搜,模拟拿牌的过程,九摞牌的状态用9位五进制表示. 代码: #include<stdio.h> #include<iostream> #include<algorithm> #include<string> #include<string.h&g…
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4512 题意: 36张牌分成9堆,每堆4张牌.每次可以拿走某两堆顶部的牌,但需要点数相同.如果有多种拿法则等概率的随机拿.例如,9堆顶部的牌分别为KS, KH, KD, 9H, 8S, 8D, 7C, 7D, 6H,则有5种拿法(KS,KH), (KS,KD), (KH,KD), (…
题意: 给出一些字符和各自对应的选择概率,随机选择L次后得到一个长度为L的随机字符串S. 给出K个模板串,计算S不包含任何一个模板串的概率 dp[i][j]表示走到AC自动机 i 这个节点 还需要走 j 步的概率. 表示不会概率DP ,看网上题解写的. 通过记忆化搜索去写. 注意一点字符有大小字母和数字 #include <set> #include <map> #include <stack> #include <queue> #include <c…
题意: 给出放一个多米诺骨牌,向左向右倒的概率,求要放好n个骨牌,需要放置的骨牌的期望次数. 分析: 用到区间dp的思想,如果一个位置的左面右面骨牌都已放好,考虑,放中间的情况, dp[i]表示放好前i个骨牌,要放的期望次数,枚举1-i,每个点做中间点求对应的期望,取最小值. dp[i]=min(L*dp[l]+R*dp[r]+1/(1.0-L-R)); #include <map> #include <set> #include <list> #include <…
题目描述 You are trying to set up a straight line of dominos, standing on end, to be pushed over later for your entertainment. (Sure, it seems pointless to set something up only to knock it down again, but you have some strange hobbies) The tricky thing…
记忆化就可以搞定,比赛里都没做出来,真的是态度有问题啊... #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ]; ]; ],n; double po(double a,int k) { double b = 1.0; while(k) { ) b = a*b; a = a*a; k = k/; } return b…
将K个模板串构成一个AC自动机,那些能匹配到的单词节点都称之为禁止节点. 然后问题就变成了在Tire树上走L步且不经过禁止节点的概率. 根据全概率公式用记忆化搜索求解. #include <cstdio> #include <cstring> #include <queue> using namespace std; ; ; ]; struct AhoCorasickAutomata { int ch[maxnode][sigma_size]; int match[ma…
#include<cstdio> #include<cstring> #include<queue> #include<cstdio> #include<map> #include<string> using namespace std; ; ; // 结点总数 + ; // 模板个数 ], n; double prob[SIGMA_SIZE]; struct AhoCorasickAutomata { int ch[MAXNODE]…
题1: Uva 1636 Headshot 题目大意: 给出一个000111序列,注意实际上是环状的.问是0出现的概率大,还是当前是0,下一个还是0的概率大. 问题比较简单,注意比较大小: A/C > B/D  <=> A * D > B * C #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> #include <iostr…
Double Patience Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 694   Accepted: 368 Case Time Limit: 1000MS   Special Judge Description Double Patience is a single player game played with a standard 36-card deck. The cards are shuffled a…