You Never Learned Geometry and Vectors?
InterviewTime limit2sMemory limit1024 MB
Count the pairs of 2D integer vectors whose dot product is zero, where a zero vector counts as perpendicular to every other vector.
Problem
Minwoo is a student who entered in 2022. When the 2022 CSAT math exam introduced elective subjects, Minwoo chose Calculus and never learned the beauty of geometry and vectors. Having taught himself geometry and vectors, he wants to show their beauty through the 2023 APC.
The dot product of two vectors and in the 2D plane is defined as follows.
If the dot product of two vectors is , the two vectors are perpendicular on the 2D plane.
Given two-dimensional vectors, count the number of ordered pairs where and vectors and are perpendicular.
Input
The first line contains . ()
From the second line onward, the next lines each contain and , separated by a space, for vector . ()
All values in the input are integers.
Output
For integers and satisfying , print the number of ordered pairs where vectors and are perpendicular to each other.