Source Code
#include<bits/stdc++.h>
using namespace std;
int main(){
      int t;
      cin >> t;
      for(int i =0; i <t; i++){
          int n, sum = 0;
          cin >> n;
          bool a = true;
          int q = 0;
          while(q<n){
              sum+= (n*n) - q*(n+1);
              q++;
          }
          
          //for(int j =1;  j <= n;j++){
            //  sum+= (j-1)*n +j;
          //}
          cout << sum << endl;
      }
}
Copy
Ali's Game Oj3far
GNU G++17
2072 ms
992 KB
Time Limit Exceeded