题目:
Description
给你长度为1~n n条边,请你求出有多少种组合方法数可以选出三条边构成三角形
Input
多组数据输入输出(数据组数考虑为最大可能性)每组数据输入一个正整数n,表示有n条长度的边可供选择(n<=10000)
Output
每组数据输出可构成三角形的边的选择方法数
Sample Input
2
4
Sample Output
0
1
代码:
#include<iostream>
using namespace std;
int main()
{
long long n;
while (
cin >> n)
cout << ((n -
1)*(n -
2)*(n -
3) /
6 + (n -
1) /
2 * (n /
2 -
1)) /
2 <<
endl;
return 0;
}