Label: style blog HTTP Io color OS for SP Div
Question link ~~ Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 2955
Question: If you are not caught, you can steal the most money,
Then the question is given the probability of being caught ~ You can consider taking the most money without being caught ..
Also RT once % >_
State equation: DP [J] = max (DP [J], DP [J-A [I] * P1 [I]);
Code ::
1 #include
HDU
POJ 2955 Brackets (range dp matching), poj2955
Brackets
Time Limit:1000 MS
Memory Limit:65536 K
Total Submissions:3951
Accepted:2078
Description
We give the following inductive definition of a "regular brackets" sequence:
The empty sequence is a regular brackets sequence,
IfSIs a regular brackets sequence, then (S) And [S] Are regular brackets sequences, and
IfAAndBAre regular brackets sequences, thenABIs a r
Question link: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 2955
Train of Thought: note that P and M [I] are the probability of being caught and cannot be used directly. They need to be converted to the probability of escaping, and then the obtained money is regarded as the volume of the backpack and then solved.
#include
Hdu-2955 (01 backpack + reverse thinking + questions)
POJ 2955 Brackets (range dp matching)
Brackets
Time Limit:1000 MS
Memory Limit:65536 K
Total Submissions:3951
Accepted:2078
Description
We give the following inductive definition of a "regular brackets" sequence:The empty sequence is a regular brackets sequence, if
SIs a regular brackets sequence, then (
S) And [
S] Are regular brackets sequences, andif
AAnd
BAre regular brackets sequences, then
ABIs a regular br
HDU 2955 Robberies (conversion probability-01 backpack)
Code:
/** Problem: HDU No. 2955 * Running time: 46 MS * Complier: G ++ * Author: ACM_herongwei * Create Time: PM on March 9, X zeroonebags * use the probability of successful escape as a value! The total amount of money in the bank is used as the capacity of the backpack! The amount of money in a single bank, and then zeronebags */# include
# In
Topic Links:Poj 2955 BracketsTitle Description:Given a string of parentheses, what is the number of parentheses with the maximum legal match?Problem Solving Ideas:Interval Dp,dp[x][y] represents the maximum number of matches in the interval [x, y), and then enumerates the interval lengths and start points. Consider that for parentheses the parentheses can be converted by state [x+1,y-1], and parentheses can be converted by [X, k) + [k, y) (x1#include
Label: style HTTP color Io OS AR for strong sp
Question Link: Http://poj.org/problem? Id = 2955
Theme: Matching brackets. The number of symmetric parentheses matches + 2. Maximum number of matches.
Solutions:
It looks like a range problem.
DP border: none. When the interval is 0, the default value is memset 0.
For DP [I] [J], if I and j match, it is not difficult to have DP [I] [J] = DP [I + 1] [J-1] + 2.
Then enumeration does not belong
Label: style blog HTTP color Io AR for SP Div
Question link: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 2955
The question is to give you a probability P, and n Banks
I want to steal money now. I can steal m yuan in every bank, but there is a probability that P will be caught.
Ask how much money you can steal if the probability of being caught is lower than P.
At the beginning, I was still thinking that the probability of Bank A being captured is
("% D",T);While(T--)// Test Data{Sum=0;Scanf("% Lf % d",P,N);// Probability of being caught and several banks P=1-P;For(I=0;IN;I++ ){Scanf("% D % lf",Bank[I].Money,Bank[I].P);// Value and probability bank[I].P=1-Bank[I].P;Sum+ =Bank[I].Money;}DoubleDP[10005] = {1.0};// Memset (DP, 0, sizeof (DP ));For(I=0;IN;I++ ){For(J=Sum;J> =Bank[I].Money;J--){If(DP[J-Bank[I].Money] *Bank[I].P>DP[J])DP[J] =DP[J-Bank[I].Money] *Bank[I].P;}}For(I=Sum;I> =0;I--){If(DP[I]-P>0.000000001){Printf("% D \ n",I);Break;
Test instructions: There are n banks, each robbing a bank, can get (v_i\) before, but there will be (p_i\) probability of being caught. Now you have to control the probability of being caught under \ (p\) , to find out how much money can be robbed.Analysis: 0-1 The deformation of the backpack, the weight into a probability, because the calculation of probability requires the product rather than the addition, so can not be directly used Dp[j] to express the probability of J maximum profit.Make \
Description: How can Roy grab the most money without being caught. It provides the money that each bank can grab and the probability of being caught.
Analysis: at the beginning, we thought that the probability was only two decimal places, multiplied by 100, and we found that the data was not like this. We decided to wa. Then I am stuck here. What should I do if the size of my backpack is not an integer. In desperation, I looked at other people's problem-solving reports and found that the money I
Question link: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 2955
Because the probability of being captured is a real number, while in the knapsack problem, the number of lower-level indicators must be an integer, so the total amount of all banks is used as the subscript here, the escape rate (1-pj) as the Dp value
During initialization, DP [0] = 1 (the escape rate is 1); the others are 0, and you can follow the 0/1 backpack.
ACCode:
Link: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 2955
Question:
The thief wants to steal money from the bank.
Give you the maximum probability of being caught, and n Banks
The N rows below represent the amount of money the bank has and the maximum probability of being arrested.
At this time, the key thing is how to write dynamic equations.
The 10 backpacks we learned are made up of two types: one is the maximum size of the backpack, and the ot
robberiesTime limit:1000MS Memory Limit:32768KB 64bit IO Format:%i64d %i64 U DescriptionThe aspiring Roy the robber have seen a lot of American movies, and knows that the bad guys usually gets caught in the end, Often because they become too greedy. He has decided to work in the lucrative business of bank robbery only for a short while, before retiring to a comfortable Job at a university.
For a few months now, Roy had been assessing the security of various banks and the amount of cash
Brackets
Topic Links:http://poj.org/problem?id=2955Test instructionsGive a string consisting only of ' (', ') ', ' [', '] ', the characters can match, the left ' (' can match to the right ') ', the left ' [' can match to the right '] 'The two matches cannot be crossed and can contain, for example, [(]) only 2 matches and [()] count four matches to find the maximum number of matches.ExercisesSet DP[I][J] for the interval I to J (set Len to interval length, J=i+len) can be obtained in the maxi
longest regular brackets subsequence is [([])] .InputThe input test file would contain multiple test cases. Each input test case consists of a single line containing only the characters ( , ) , [ , and ] ; each input t EST would have length between 1 and inclusive. The End-of-file is marked by a line containing the word "end" and should not being processed.OutputFor each input case, the program should print the length of the longest possible regular brackets subsequence on a single Line.Sample
http://poj.org/problem?id=2955The main idea is to give you a string, which consists of brackets and parentheses, and asks how long the longest one in the string matches the mathematical brace matching specification.At first, I intend to use the legend of the left closed to open the interval to write, and later found that it is not suitable for me, or to return to the left closed right closed interval write.DP's idea is simple, dp[i][j] represents the oldest sequence of strings that match parenth
integer Mj and a floating point number Pj.Bank J contains Mj millions, and the probability of getting caught from robbing it's Pj.Outputfor each test case, output a line with the maximum number of millions he can expect to get while the probability of Getting caught is less than the limit set.Notes and Constraints0 0.0 0 0 0.0 A Bank goes bankrupt if it is robbed, and your may assume that all probabilities be independent as the police have very lo W funds.Sample Input3 0.04 31 0.022 0.033 0.050
integer Mj and a floating point number Pj.Bank J contains Mj millions, and the probability of getting caught from robbing it's Pj.Outputfor each test case, output a line with the maximum number of millions he can expect to get while the probability of Getting caught is less than the limit set.Notes and Constraints0 0.0 0 0 0.0 A Bank goes bankrupt if it is robbed, and your may assume that all probabilities be independent as the police have very lo W funds.Sample INPUT3 0.04 3 1 0.02 2 0.03 3 0.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.