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

void solve(){
    long long n;
    cin>>n;
    long long sum = (1+n*n) / 2 * n;
    cout<<sum<<endl;
}

int main(){  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    // freopen("input.txt", "r", stdin);

    int t = 1;
    cin>>t;
    while(t--)
        solve(); 
}
Copy
Ali's Game hashemtb
GNU G++17
1 ms
240 KB
Wrong Answer