UVa 11401


http://uva.onlinejudge.org/index.php?option=com_オンラインjudge&Itemid=8&page=show_problem&problem=2396
組み合わせ。後で導出過程を書きます。
#include<iostream>

using namespace std;

const int maxn=1000010;

long long num[maxn];

int main()
{
    num[3]=0;
    for(long long i=4; i<maxn; i++)
    {
        num[i]=num[i-1]+((i-1)*(i-2)/2-(i-1)/2)/2;
    }
    int n;
    while(cin>>n)
    {
        if(n<3)
        {
            break;
        }
        cout<<num[n]<<endl;
    }
}