Wiring
Time limit1sMemory limit256 MB
Count how many distinct wires appear after N squared triangular steps join nails around a circle.
- Level
Medium7 of 10
- Topics
- Number theory, Math
- Solved
- No attempts yet
Problem
There are nails driven into the rim of a large circle at equal spacing. Call one of them , then name the rest through going clockwise.
Wires are connected by the following rule.
- Let .
- Repeat step from step to step . If , set and join to with a wire. If the two nails are already joined, no new wire is added. If and are the same nail, no wire is added.
Find how many wires are connected once every step is done.
Input
The first line contains a natural number . ()
Output
Print the number of connected wires on the first line.