hi, Can anyone(who got Ac) help me abt 10891? Can u tell me how to proceed to solve the problem?
And I am afraid abt 10892 that i wont solve it within given time. So pls show the way to solve it
What does the phrase "consecutive numbers" mean? Does that mean that the numbers themselves are consecutive (like "1, 2, 3" or "6, 5, 4"), or does it simply mean that they are consecutive inside the array?
Also, could anyone please explain why the answer to the first test case is 7?
If only I had as much free time as I did in college...
sorry,i don't very agree with you.
if you are right,i can do this:
A takes 7;
B takes 4;
A takes -10;
B takes -20;
then A is -3 and B is -16;
the answer is 13 greater than 7.
shamim is correct. Abednego's method gives an answer of -7, not 7.
oulongbin, both players play to get the maximum difference, so if A takes 7, B will take 4 and -10, leaving A with -20 so that B wins with -6 vs. -13. B wouldn't let A pick between -10 and -20 when B could have taken the -10 leaving A with the -20.
cool. I couldn't figure that test case out until reading this thread. However, my program got AC during the contest. That's the magic about dynamic programming. You don't know what it does, but it eventually solves all your problems.
Hi
in problem 10892
- I have solved this problem by this way
- first i have stored all factor's of the given number
- then a n square loop to find out the LCM Cardinality.
- if two factor's lcm is N then i have increased my counter variable.
- then just print the counter variable.
and in problem 10891 is a game theory problem
- you can solve this probem by using memoization.
jdmetz wrote:shamim is correct. Abednego's method gives an answer of -7, not 7.
oulongbin, both players play to get the maximum difference, so if A takes 7, B will take 4 and -10, leaving A with -20 so that B wins with -6 vs. -13. B wouldn't let A pick between -10 and -20 when B could have taken the -10 leaving A with the -20.
ibrahim wrote:Anbody can explain the algorithm (DP). I am not getting the right process.
Simple
For each segment of the input sequence you want to compute the result of the given game.
Note that after the first move of player A they are playing exactly the same game on the rest of the sequence, player B starts.
Example: If the value of player A's move is 4 and the result of the game on the rest of the sequence is 7, the result of the whole game is 4-7=-3.