Square Board : Grasshoper on ChessBroad
0
of 0 votes
1
Answer
Unable to get what exactly the Question Is?
so What is the whole logic behind this question .It seems to be complete Math problem to me.
There is a Grasshopper in a tropical forest. The grasshopper can jump only vertically and horizontally, and the length of jump is always equal to x centimeter. A GRasshopper has found herself at the center of some cell of the chess board of the size pxq centimeters(each cell is 1x1 centimeters). She can jump as she wishes for an arbitrary number of times, she can even visit a cell more than once. the only restriction is that she cannot jump out of the board.
The grasshopper can count the number of cells that she can reach from the starting position(x,y). Let's denote this amount by dx,y. your task is to find the number of such starting position(x,y), which have the maximum possible value of dx,y
Input
The integer array contains three integers p,q,x
p= length of the board
q= width of the board
x=length of the grasshoppers jump.
Output
Output the only integer - the number of the required starting position of the Grasshopper
Example
input 2 3 1000000
output 6
input 3 3 2
output 4
Regards,
JSD
Suppose you place the grasshopper at a particular cell (a,b). Now count the number of cells the grasshopper can reach (called da.b). Note that it can only jump x centimeters at a time.
- Anonymous April 03, 2014Do this counting for each cell. Find the cells which have maximum possible da.b value. Output the count.
This can be done via programming brute force.
But yes, seems like there should be an easy mathematical solution.