Friday, September 19, 2014

Little Vaishnavi and plywood


Problem

Idea : For this problem , given the position of damaged wood m and the number of jump k that the damaged wood can tollarate over it .You have to count the number of jump until the damaged wood break down .

Here we have to handle the following cases-

1 . m = 1 and k = 0 or k>0
2 . m = 5 and k = 0 or k>0
3 . 1<m<5 and k is even or k is odd.

1 . If m = 1 , that means the damaged wood is in first position .
For that ,
If the value of k = 0 , we can not make any jump .
If the value of k is other than 0 ,
For this situation ,
If k=1 , Number of jump = 8
If k=2 , Number of jump =16
If k=n , Number of jump =8*n


2 . If m = 5 , that means the damaged wood is in last position .

For that ,
If the value of k = 0 , we can make 4 jumps .
If the value of k is other than 0 ,
For this situation ,
If k=1 , Number of jump =12
If k=2 , Number of jump =20
If k=n , Number of jump =8*n +4

3 .  If the value of m is not 1 and not 5 .

If k is even ,the number of jump is 4*k+(m-1)
If k is odd , the number of jump is 4*k+(5-m)

My Solution





No comments:

Post a Comment