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

int main()
{
  int t;
  cin>>t;
  while(t--)
  {
      long long  n;
      cin>>n;
      long long x=n-1;
      long long z=n-1;
      long long y=n;
      long long h=n-1;
      long long sum=n;
      while(z--)
      {
          sum+=(x+y);
          x+=h;
      }
      cout<<sum<<"\n";
  }
}
    /*int n,k;
     long long  arr[1000001];
    cin>>n>>k;
    for(int i=0;i<n;i++)
    cin>>arr[i];
    if(n==1)
    cout<<arr[0];
    else
    {
   
    
    sort(arr,arr+n);
    cout<<arr[n-1]+arr[0];
    }
}
   /* long long  n,k;
    cin>>n>>k;
    
    long long arr[1000001];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    if(n==1)
    cout<<arr[0];
    else
    {
    long long sum=0;
    sort(arr,arr+n);
    if(n%2==0)
    {
        for(int j=0;j<n;j+=k)
        sum+=arr[j];
    }
    else
    {
        for(int j=1;j<n;j+=k)
        sum+=arr[j];
    }
    cout<<sum;
    }
}*/
Copy
Ali's Game Nada M
GNU G++17
2087 ms
1.4 MB
Time Limit Exceeded