【HDU 2955】Robberies(DP)】的更多相关文章

题意是给你抢劫每个银行可获得的钱m和被抓的概率p,求被抓的概率小于P,最多能抢多少钱.01背包问题,体积是m,价值是p.被抓的概率不是简单相加,而应该是1−Π(1−p[i])DP:dp[i]表示抢到i元且不被抓的概率.初始条件:dp[0]=1:转移方程:dp[j]=max{dp[j],dp[j−m[i]]∗(1−p[i])}(j>=m[i]) #include<cstdio> #include<cstring> #include<algorithm> #defin…
BUPT2017 wintertraining(15) #8F 题意 1到n的排列,经过几次置换(也是一个排列)回到原来的排列,就是循环了. 现在给n(<=1000),求循环周期的所有可能数. 题解 问题等价于几个正整数加起来等于n,求最小公倍数的可能数. 因为1不影响最小公倍数,所以等价于求几个正整数加起来小于等于n,最小公倍数的可能数. 最小公倍数与每个质因子在正整数里最大出现次数有关,所以枚举质因子的幂,进行dp. dp[i][j]表示前i个质数,和为j时,最小公倍数的可能数. dp[0]…
[POJ 3071] Football(DP) Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4350   Accepted: 2222 Description Consider a single-elimination football tournament involving 2n teams, denoted 1, 2, -, 2n. In each round of the tournament, all tea…
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 21981 Accepted Submission(s): 8121 Problem Description The aspiring Roy the Robber has seen a lot of American movies, and knows that the bad guys us…
-->Nightmare Ⅱ 原题太复杂,直接简单的讲中文吧 Descriptions: X表示墙 .表示路 M,G表示两个人 Z表示鬼 M要去找G但是有两个鬼(Z)会阻碍他们,每一轮都是M和G先走M能走3步,G能走1步,Z每次向边上2步内变出分身.求所需最短时间. 鬼能穿墙,人不能 Sample Input 3 5 6 XXXXXX XZ..ZX XXXXXX M.G... ...... 5 6 XXXXXX XZZ..X XXXXXX M..... ..G... 10 10 ........…
题意:一共有N只牡牛(公牛)和牝牛(母牛),每2只牡牛间至少要有K只牝牛才不会斗殴.问无斗殴发生的方案数. 解法:f[i][j]表示一共i只牛,最后一只是j(0为牝牛,1为牡牛)的方案数.f[i][0]=f[i-1][1]+f[i-1][0]; f[i][1]=f[i-k-1][1]+f[i-k-1][0](这个小心不要漏了,因为没有要求2只牡牛间一定是K只牝牛); 1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstri…
Phalanx 先搬翻译 Descriptions: 给你一个矩阵,只由小写或大写字母构成.求出它的最大对称子矩阵的边长. 其中对称矩阵是一个k*k的矩阵,它的元素关于从左下角到右上角的对角线对称.例如下面这个3* 3的矩阵是对称矩阵:cbxcpbzcc Input 多组数据.每一组第一行是一个 n (0<n<=1000),下面是n行,每一行有n个字母,中间没有空格.数据以n=0结束. Output 每组数据输出最大的对称矩阵的边长. Sample Input 3 abx cyb zca 4…
Assignment Problem Description Last year a terrible earthquake attacked Sichuan province. About 300,000 PLA soldiers attended the rescue, also ALPCs. Our mission is to solve difficulty problems to optimization the assignment of troops. The assignment…
Problem Description Mr. Panda lives in Pandaland. There are many cities in Pandaland. Each city can be treated as a point on a 2D plane. Different cities are located in different locations. There are also M bidirectional roads connecting those cities…
Escape  Descriptions: 一个人从(0,0)跑到(n,m),只有k点能量,一秒消耗一点,在图中有k个炮塔,给出炮塔的射击方向c,射击间隔t,子弹速度v,坐标x,y问这个人能不能安全到达终点要求: 1.人不能到达炮塔所在的坐标2.炮塔会挡住子弹3.途中遇到子弹是安全的,但是人如果停在这个坐标,而子弹也刚好到这个坐标,人就被射死4.人可以选择停止不动 Input 对于每个测试用例,第一行有四个整数,m.n.k和d (2<=m, n<=100, 0<=k<=100, m…