UVA-11401 - Triangle Counting

  • UVa Online Judge 解題結果請於 Submit 後,參閱 uHunt
  • 如果你有任何建議與指教,歡迎於下方留言一起討論喔!
  • 本題選為「20161220 大學程式能力檢定 CPE」題目。
  • 相同題目:NCTU-10920

題意概要

題目給定 個長度不同的桿子,其長度分別為 ,…,,從中選出三個不同的桿子以組成一個三角形,請問共有幾種組合方式?


Input

The input for each case will have only a single positive integer (). The end of input will be indicated by a case with . This case should not be processed.


Output

For each test case, print the number of distinct triangles you can make.


Sample Input

5
8
0

Sample Output

3
22
profile-image
David Lu
Hello, I'm David Lu. I am a graduate student in Department of Computer Science at National Chiao Tung University, Taiwan. I am in the Networking and Sensing Systems (NSS) Lab at NCTU. If you have any question, please feel free to contact with me.
comments powered by Disqus