Hopscotch
Time limit2sMemory limit512 MB
Count lattice paths from (0,0) to (N,N) where each hop increases x by at least X and y by at least Y, modulo 1e9+7.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Combinatorics, Math, Prefix sum
- Solved
- No attempts yet
Problem
You are playing hopscotch. You start at the origin and your goal is to hop to the lattice point . A hop takes you from a lattice point to a lattice point with and .
You dislike short hops. So you have decided that on every hop between two lattice points, the -coordinate must increase by at least and the -coordinate must increase by at least .
Count the distinct paths from to that respect these constraints. Two paths are distinct if there is some lattice point that you visit on one path and not on the other.
Hint: the answer is taken modulo . If is a prime such as and is an integer that is not modulo , then .
Input
The first line holds three integers , , separated by single spaces. You may assume .
Output
The number of distinct paths can be very large. Print that number modulo () on one line.