Professional Documents
Culture Documents
http://www.questtosolve.com/browse.php?pid=10790
Solved By:
wesley
Theory Difficulty:
easy
Coding Difficulty:
trivial
Algorithms Used:
math
Solution Description:
To get a feel for how the pattern in this problem
works, take the example of four dots in the bottom row, and one dot on top.
Let the dots in the bottom be B1...B4, and the dot on top be A1. There are no
points of intersection.
If we add another dot on top (A2), then the line A2-B1 crosses 3 lines, A2-B2
crosses 2 lines, A2-B3 crosses 1 line, and A2-B4 crosses 0.
0
3+2+1
6+4+2
9+6+3
...
Or more explicitly:
0
1 * (3 + 2 + 1)
2 * (3 + 2 + 1)
3 * (3 + 2 + 1)
tri(A) * tri(B)
= A(A-1)/2 * B(B-1)/2