Source Code
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

vector<long long> pre(100001);
void prepare(){
	pre[1] = 1;
	for(int i = 2; i < 100001; i++){
		pre[i] = pre[i-1] + (i-1)*(i-2)/2 + (i * i);
	}
}

int main(){
	prepare();
	int t;
	cin >> t;
	while(t--){
		int n;
		cin >> n;
		cout << pre[n] << endl;	
	}
		
		
	
	return 0;
}
Copy
Ali's Game MohaDarkness
GNU G++17
371 ms
2.4 MB
Wrong Answer