stould's blog

By stould, 11 years ago, In English

I was trying to solve the following problem:Death Row

I spent the whole morning trying to solve it, but just wrong answer.. I just realized that the minimum time that he and his family still living is when Yama at every visit, kills M people and (N-M) >= 2, and when is remaining just N = 2 people, Yama need to visit more two times. I guess it is right, but I'm receiving wrong answer..

Can someone help me ? Thanks in advance.

  • Vote: I like it
  • +5
  • Vote: I do not like it

»
11 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

If I understood the problem correctly then this is the solution:

If n ≤ 3 then answer is n

else if n is even then answer is 3

else answer is 4.

Reasoning is trivial.

  • »
    »
    11 years ago, hide # ^ |
    Rev. 5  
    Vote: I like it +5 Vote: I do not like it

    I used this strategy but I do not check when N is even (the answer is 3 intead of 4). Can you explain it to me ?

    Thank you.

    • »
      »
      »
      11 years ago, hide # ^ |
       
      Vote: I like it +1 Vote: I do not like it

      From what I understood the you can either reduce a number by one or reduce a number to some non-trivial factor of itself.

      For all even numbers reduce it to 2 in its first step and then take 2 steps to get to 0.

      For all odd numbers subtract 1 on first step to make it even, then take 3 steps to get to 0.