Source Code
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n,sum=0;
		scanf("%d",&n);
		int i=1,j=n;
		while(i<=n&&j>=1)
		{
		      sum+=((i-1)*n + j);
		      i++;
		      j--;
		}
		printf("%d",sum);
		printf("\n");
	}
	return 0;
}
Copy
Ali's Game lanooshkh
GNU G++17
2074 ms
1.3 MB
Time Limit Exceeded