Problem Description
Loading...
Problem Analysis
Since not every pair of lines intersects, we need to determine the number of parallel lines
For each n, if there are j parallel lines, we can loop over and check
Obviously, the intersection points contributed by parallel lines are
number of parallel lines * number of non-parallel lines
The non-parallel lines can also have various combinations of intersection point counts
So we can add them recursively, adding the possible counts for the non-parallel lines
That is, dp[i]=(i-j)*j+dp[i-j]
It is clear that this method also includes cases where the non-parallel lines contain parallel lines
But this does not affect the result; it only causes duplicate output
So we just need to check whether this point-count scheme has been used before
cpp
| |