Number of upward triangles of side length k where biggest triangle size is n
(n>=k) is
 1 + 2 + ... + (n-k+1) = (n-k)(n-k+1)/2

Number of downward triangles of side length k where biggest triangle size is
n (n>=2k) is
1 + 2 + ... + (n-2k+1) = (n-2k)(n-2k+1)/2

Therefore answer is
[(sigma, 1, n) (n-k)(n-k+1)/2] + [(sigma, 1, (int)n/2) (n-2k)(n-2k+1)/2 ]

Using formulas for sigma of 1 to n of k and k^2, you can easily derive the
formula now

-Bharath

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-codejam" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to