UVA 13108 Solution

#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
    int t,n;
    scanf("%d",&t);
    while (t--)
    {
        scanf("%d",&n);
        int ans=n*(n-1)/2+n*(n-1)*(n-2)*(n-3)/24+1;
        printf("%d\n",ans);
    }
    return 0;
}

Comments

Popular posts from this blog

Codeforces 698A - Vacations

UVA 11364: Parking -Solution

UVA 10550 - Combination Lock : Solution