Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Given N*M grid in which one cell contains a ball and all other cells are empty in all other boxes i am provided with one of these 8 directions towards the right position of ball.These are :

1.Exactly Above it
2.Exactly Below it
3.Exactly To the Right
4.Exactly To the Left
5.In the Top Right Region
6.In the Bottom Right Region
7.In the Top Left Region
8.In the Bottom Left Region

How to find the ball in minimum moves.So we need to tell minimum moves required to find the ball.

Note : N and M can go upto 10^19 so we cant make a 2D Grid and then solve.

EXAMPLE : If N=3 and M=3 then here minimum moves is 1

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.