Source Code
#include <iostream>
#include<algorithm>
#include <cmath>
using namespace std;


int main() {
	int t;
	cin >> t;
	int n;
	for (int i = 1; i <= t; i++) {
		cin >> n;
		int sum = 1;
		int k =n*n;
		for (int j = 1; j < n; j++)
		{
			sum = sum +k;
			k = k-n-1;
		}
		cout << sum<<endl;
	}
	
	
	
	return 0;

}
Copy
Ali's Game hoodlum awm
GNU G++17
1749 ms
1.9 MB
Wrong Answer