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(10^{8}) not T(108) :P.

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

According to the cosine theorem , we have

c^{2} = a^{2} + b^{2} - 2abcos120° = a^{2} + b^{2} + ab.

Let d = b - a, after a simple calculation, we get: c^{2} = 3a (a + d) + d^{2} . 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:

1 Like