Nearly isosceles 120 degree triangles problem

Let a, b and c be the sides of an integer sided triangle with one angle of 120 degrees, a≤b≤c and b-a≤100.
Let T(n) be the number of such triangles with c≤n.
T(1000)=235 and T(108)=1245.
Find T(10100).

Firstly, googling the question I understand you meant finding T(108) not T(108) :P.

Secondly the question involves using Cosine Law: cc=aa+bb-2abcos©=aa+b*b+ab

According to the cosine theorem , we have
c2 = a2 + b2 - 2abcos120° = a2 + b2 + ab.
Let d = b - a, after a simple calculation, we get: c2 = 3a (a + d) + d2 . Obviously, d can not be zero (otherwise, √3̅ is a reasonable number).

So the question simply wants you to iterate and check but it can be time consuming.
You can learn more its optimization about this question’s algorithm from these links:

Chinese Conversion to English

Law of Cosines

1 Like