Manhattan
Time limit1sMemory limit1024 MB
Count the distinct lattice paths that start in zone Z1 and end in zone Z2 for two non-overlapping rectangles, modulo 666013.
- Level
Medium7 of 10
- Topics
- Combinatorics, Math
- Solved
- No attempts yet
Statement
In the first quadrant of the Cartesian plane, a zone, denoted , is the set of lattice points in the rectangle with diagonally opposite corners and , where and . A zone can lie on a single segment when or , and it is a single point when and .
A path between two lattice points is a minimal set of horizontal and vertical unit segments that join the two points.
Given two zones and that share no point, count the distinct paths that start in and end in , modulo .
Input
The first line contains eight integers , the boundaries of the two zones.
Output
Print a single integer, the number of paths modulo .