Source Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{

    ios_base::sync_with_stdio(0);
    cout.tie(0); cout.tie(0);

    int tt;
    cin >> tt;
    while(tt--)
    {
        ll n;
        cin >> n;
        ll ans = 0;
        for(ll i = 1 ; i <= n * n ; i += (n + 1)) {
            ans += i;
        }
        cout << ans << '\n';
    }
    return 0;
}
Copy
Ali's Game Greedious
GNU G++17
2084 ms
1.7 MB
Time Limit Exceeded