HUD3689 Infinite monkey theorem】的更多相关文章

Infinite monkey theorem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1703    Accepted Submission(s): 883 Problem Description Could you imaging a monkey writing computer programs? Surely monke…
Infinite monkey theorem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1702 Accepted Submission(s): 882 Problem Description Could you imaging a monkey writing computer programs? Surely monkeys are…
J - Infinite monkey theorem Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 3689 Appoint description:  System Crawler  (2014-11-09) Description Could you imaging a monkey writing computer progra…
Infinite monkey theorem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)http://acm.hdu.edu.cn/showproblem.php?pid=3689 Problem Description Could you imaging a monkey writing computer programs? Surely monkeys are sma…
Description Could you imaging a monkey writing computer programs? Surely monkeys are smart among animals. But their limited intelligence is no match for our human beings. However, there is a theorem about monkeys, and it states that monkeys can write…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3689 黄老师说得对,题目只有做wa了才会有收获,才会有提高. 题意:一个猴子敲键盘,键盘上有n个键,猴子敲第i个键的概率是p[i],问敲m次后形成的字符串里出现给定串的概率是多少. 这实际上就跟那个ac自动机转为trie图然后dp一样的. 类似的题目有POJ 2778,这篇题解不错:http://blog.csdn.net/luyuncheng/article/details/8643001 只不过…
题链: http://acm.hdu.edu.cn/showproblem.php?pid=3689题解: KMP,概率dp (字符串都从1位置开始) 首先对模式串S建立next数组. 定义dp[i][j]表示猴子打的串长度为i,且该串的后缀与模式串最多匹配到j位置的概率. 显然dp[0][0]=1, 考虑如何转移: 枚举下一个打出的字符为c,然后用kmp的next数组找到模式串中可以继续匹配的位置k. 即:k=j+1; while(k&&S[k]!=c) k=next[k]; 然后将dp…
有一只猴子随机敲键盘,给出它可能敲的键以及敲各个键的概率. 输入:n,表示有多少个键,m,表示猴子会敲m次键 n个二元组(字母,数字) 表示键代表的字母及其被敲的概率. 最后一个目标字符串. 问这只猴子敲了m次键后得到的字符串包含目标字符串的概率. 最主要的还是怎么定义出具有无后效性的状态. 用dp[i][j]表示扫描第i位,前面未曾出现完全匹配并且后缀与target已匹配长度为j的概率 然后模仿kmp匹配的过程进行dp就可以了. AC代码: #include<bits/stdc++.h> u…
题意:问随机生成一个长度为m(m<=1000)长度的字符串,出现某个子串s的概率是多少. /* KMP+DP 设f[i][j]表示A生成到第i位,此时B串匹配到第j位的概率. 转移方程为f[i+1][k]+=f[i][j]*lv(枚举的第i位生成字符的概率) k位如果第i位生成该字符,那么它能和B串匹配到的地方. */ #include<cstdio> #include<iostream> #include<cstring> #define N 1010 usin…
题目描述: 大概的意思就是根据无限猴子定理,无限只猴子坐在打字机旁瞎敲,总有一个能敲出莎士比亚文集.现在给你一个打字机和一只猴子,打字机的每个按钮(共n个)上的字母及猴子按下这个按钮的概率已知,而且猴子只能按m下按钮,又给定一个串,问猴子打出的乱码中含这个串的概率. 其中n<=26,m<=1000,多组数据,以n=0,m=0结束.以百分数形式输出,保留小数点后2位. 样例: 输入: 4 10 w 0.25 o 0.25 r 0.25 d 0.25 word 2 10 a 1.0 b 0.0 a…