Greeting Card
Time limit2sMemory limit512 MB
Count how many pairs of given lattice points lie exactly 2018 units apart.
- Level
Medium6 of 10
- Topics
- Hash map, Math, Geometry, Brute force
- Solved
- No attempts yet
Problem
Quido is sending a new year greeting to his friend Hugo, and he prints the card on a high precision plotter.
The plotter works in two steps. First it plots a pattern of dots on the paper. Then it draws a straight segment between every pair of dots that lie exactly length units apart.
The plotter prints with a special holographic ink that is in short supply, so Quido wants to know how many segments the picture contains before he starts the job.
Input
The first line contains a positive integer , the number of plotted points. Each of the next lines contains two space separated integers, the coordinates of one point. Every coordinate is non-negative and smaller than . There are at most points and all of them are distinct.
All coordinates and distances are given in plotter length units, and one unit in the x direction has the same length as one unit in the y direction.
Output
Print one integer, the number of pairs of points whose distance is exactly .