AlgoUniversity
  • Go Back
Discussion
Hungry Rabbit :

Author

Manas

Difficulty Level : Medium

Submissions : 343

Asked In : OYO

Marks :10

: 6 | : 0

There is m*n table with a rabbit in one of the cell - rabbit is initiall at position [startR, startC] . rabbit is Hungry, want to eat something and crying. He is trying to come out of the table, rabbit is allowed to move to one of the four adjacent cells of a table, rabbit can move at most max no of moves(maxMoves).

Given integers m, n, maxMoves, startR, startC, return number of paths to move the rabbit out of the cell. The result might be very Large, return it using modulo 10^9+7

Example 1

Input m= 2, n = 2, maxMoves = 2, startR = 0, startC = 0

Output: 6

Example 2

Input m= 1, n = 3, maxMoves = 3, startR = 0, startC = 1

Output: 12

Constraints:

1 <= m, n <= 50

0 <= maxMove <= 50

0 <= startRow < m

0 <= startColumn < n

Input

The input will contain 5 values: m, n, maxMove, startRow, startColumn

Output

The output should contain one integer which is the answer mod 10^9 + 7.

Example

Input
1 4 3 0 1
Output
14

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.