Bouncing Ball Steps
There is a ball at the top-left corner of an n \times m grid. The rows of the grid are numbered 1,2,\dots,n, and the columns are numbered 1,2,\dots,m. The ball is initially moving diagonally away from the top-left corner. At every step, it moves one cell. Whenever the ball hits the border of the grid, it changes its direction. What is the location of the ball after k steps and how many times has
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start