# The bouncing ball

**Number Theory**Level 4

I've posted a question, so to celebrate, I decided to play pool. Somehow my house has tables with holes at four corners of any dimensions. The ball and the holes are negligibly small (epsilon by epsilon).

My mathematical friend says, "I will give you a \(m\times n\) rectangular table where \(m, n\) are positive integers summing to 2015. It's up to me to decide. Hahaha. Then we will play." Then he will put the ball at one corner.

I am very bad at aiming, so I only have a machine that will shoot the ball at an angle of 45° to the sides of the table. My evil friend wants the ball to bounce as many times as possible before it reaches any hole so that the ball can lose as much kinetic energy as possible and leave me in suspense.

I calculate that the maximum number of bounces is \(M\).

For how many ordered pairs \((m, n)\) does the number of bounces equal \(M\)?

Clarifications:

As an explicit example, a \(1\times2\) table needs 1 bounce, and a \(2\times3\) table needs 3 bounces. A \(1\times2014\) table needs 2013 bounces.

You may make the assumption that we are decent mathematicians, although we can't play pool and do weird things. Note also that this is combinatorics, not computer science.