[Python3] combinatorics
IntuitionI used DP O(MN) to solve it but found this solution from @lee215 which is more efficient.ApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
I used DP `O(MN)` to solve it but found this solution from @lee215 which is more efficient. 

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```Python3 []
class Solution:
    def distanceSum(self, m: int, n: int, k: int) -> int:
        mod = 1_000_000_007 
        ans = 0
        for d in range(1, n): 
            ans = (ans + d * (n-d) * m * m) % mod 
        for d in range(1, m): 
            ans = (ans + d * (m-d) * n * n) % mod 
        return ans * comb(m*n-2, k-2) % mod 
```
['Python3']