Source Code

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

int main()
{
     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  ll t,n;
  cin>>t;
  while(t--){
      cin>>n;
      ll ans=1+n*n;
     ll x=ans/2;ans*=(n/2);
      if(n%2==1){
          ans+=x;
      } 
       
      
      cout<<ans<<"\n";
      
     
      
  }
   
      return 0;
}
Copy
Ali's Game ateeq
GNU G++17
118 ms
2.2 MB
Accepted