We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home
  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Mathematics
  3. Combinatorics
  4. Grid Lines

Grid Lines

Problem
Submissions
Leaderboard
Discussions

In an NxM grid with each cell's dimension being 1x1, there will be (N+1) x (M+1) cross points. You task is to count the number of ways (S) of choosing K different points from these cross points such that all of them lie on a straight line and at least one of the cross points lies on the border.

Input Format

A single line containing 3 integers N, M & K separated by a single space.

Output Format

A single integer denoting the number of ways (S) modulo 1000000007

Constraints

0 < N, M <= 3000
2 <= K <= max(N, M) + 1

Sample Input

2 2 3

Sample Output

8

Explanation

If you imagine a grid of the first quadrant of the co-ordinate system. Then, we have, 8 such 3 points of which at least 1 point on the borders.

(0,0), (0,1), (0,2)
(1,0), (1,1), (1,2)
(2,0), (2,1), (2,2)
(0,0), (1,0), (2,0)
(0,1), (1,1), (2,1)
(0,2), (1,2), (2,2)
(0,0), (1,1), (2,2) and
(0,2), (1,1), (2,0)

Author

idlecool

Difficulty

Hard

Max Score

80

Submitted By

216

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Helpdesk
  • Careers
  • Terms Of Service
  • Privacy Policy

Cookie support is required to access HackerRank

Seems like cookies are disabled on this browser, please enable them to open this website

Join us

Create a HackerRank account

Be part of a 26 million-strong community of developers

Please signup or login in order to view this challenge

or
Already have an account?Log in