HDOJ 2955】的更多相关文章

Robberies 算法学习-–动态规划初探 题意分析 有一个小偷去抢劫银行,给出来银行的个数n,和一个概率p为能够逃跑的临界概率,接下来有n行分别是这个银行所有拥有的钱数mi和抢劫后被抓的概率pi,求在不被抓的情况下,小偷能抢到的最多的钱是多少. 显然这是一道概率问题,计算小偷不能逃的概率是不好算的,不如计算他成功的概率.若把题目中每个数据变成能够逃跑的概率,那就是1-pi. 我们先举个简单的例子. 不妨假设有3个银行: ①如果小偷都能抢劫,那么抢劫后能逃跑的概率就是(1-p1) * (1-p…
10397780 2014-03-26 00:13:51 Accepted 2955 46MS 480K 676 B C++ 泽泽 http://acm.hdu.edu.cn/showproblem.php?pid=2955 Robberies Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9836    Accepted Submis…
Robberies Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 15522    Accepted Submission(s): 5708 Problem Description The aspiring Roy the Robber has seen a lot of American movies, and knows that…
这道背包题和我们常见的背包题有所不同.如果根据以前做背包的惯性思维和题中数据的迷惑,会把概率乘以100来当作容量.但是经测试是不行的. 我们不妨换种思路,看做DAG上的DP思想.将所有有可能达到的钱的最大"逃跑"概率算出来,最后再将能够达到的最大的钱输出.而能不能够达到这个可以将所有除0以外的值初始化为0.意为逃跑的概率为0. #include<cstdio>#include<cstring>#include<algorithm>using name…
01背包.将最大金额作为容量v.概率做乘法. #include <stdio.h> #include <string.h> #define mymax(a, b) (a>b) ? a:b ]; ]; ]; int main() { int case_n; float ff, f; int m, v; int i, j; scanf("%d", &case_n); while (case_n--) { scanf("%f %d",…
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 56784    Accepted Submission(s): 19009 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats g…
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3049    Accepted Submission(s): 2364 Problem Description You are the CEO of Nasty Hacks Inc., a company that creates small pieces of…
Box of Bricks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5994    Accepted Submission(s): 2599 Problem Description Little Bob likes playing with his box of bricks. He puts the bricks one up…
题目链接:http://poj.org/problem?id=2955 思路:括号匹配问题,求出所给序列中最长的可以匹配的长度(中间可以存在不匹配的)例如[(])]有[()]符合条件,长度为4 dp[i][j]代表从区间i到区间j所匹配的括号的最大个数,首先,假设不匹配,那么dp[i][j]=dp[i+1][j]:然后查找i+1~~j有木有与第i个括号匹配的 有的话,dp[i][j]=max(dp[i][j],dp[i+1][k-1]+dp[k][j]+2)..... #include<cstd…
Problem Description Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color…