Unit Squares Along a Diagonal
Time limit1sMemory limit128 MB
Given N, count unordered integer side pairs (a,b) such that a+b-gcd(a,b) equals N, using the diagonal-crossing formula for a grid rectangle.
- Level
Medium6 of 10
- Topics
- Number theory, Math, Combinatorics
- Solved
- No attempts yet
Problem
is a rectangle whose side lengths are integers. It can be tiled exactly by unit squares, each with side length .
Define as the number of unit squares that one diagonal of the rectangle passes through. For example, a rectangle with side lengths and has .
Given a natural number , count the number of rectangles that satisfy . A rectangle with side lengths and is considered the same as one with side lengths and .
Input
The first line contains a natural number ().
Output
Print the number of rectangles satisfying on the first line.
Hint
Think about how to express, using only the two side lengths and , the number of unit squares that the diagonal of an rectangle passes through.