ITGUY18 - Editorial





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.


#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;
1 Like

Hello, how did I get WA with this code?

There is some prob with __int128

On my machine it got exactly the same outputs for all possible N; think there are some troubles with codechef judge machine or IDK.

Can you please explain how you came up with this solution?