Problem: https://www.codechef.com/PBK12020/problems/ITGUY18
DIFFICULTY:
EASY.
PROBLEM:
The chef is placing the laddus on the large square plat. The plat has the side of length N. Each laddu takes unit sq.unit area. Cheffina comes and asks the chef one puzzle to the chef as, how many squares can be formed in this pattern with all sides of new square are parallel to the original edges of the plate.
Program:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false), cin.tie(NULL);
ll t;
cin >> t;
while (t--) {
ll n;
cin >> n;
ll ans = n * (n + 1);
ans = ans * (2 * n + 1);
ans /= 6;
cout << ans << '\n';
}
return 0;
}