HackerEarth Cube Change problem solution YASH PAL, 31 July 2024 In this HackerEarth Cube Change problem solution Chandan gave his son a cube with side N. The N X N X N cube is made up of small 1 X 1 X 1 cubes. Chandan’s son is extremely notorious just like him. So he dropped the cube inside a tank filled with Coke. The cube got totally immersed in that tank. His son was somehow able to take out the cube from the tank. But sooner his son realized that the cube had gone all dirty because of the coke. Since Chandan did not like dirty stuffs so his son decided to scrap off all the smaller cubes that got dirty in the process. A cube that had coke on any one of its six faces was considered to be dirty and scrapped off. After completing this cumbersome part his son decided to calculate volume of the scrapped off material. Since Chandan’s son is weak in maths he is unable to do it alone. Help him in calculating the required volume. HackerEarth Cube Change problem solution. #include <bits/stdc++.h>#define _ ios_base::sync_with_stdio(false);cin.tie(0);using namespace std;#define pb push_back#define pob pop_back#define pf push_front#define pof pop_front#define mp make_pair#define all(a) a.begin(),a.end()#define bitcnt(x) __builtin_popcountll(x)#define MOD2 1000000007#define BASE1 31#define BASE2 255#define MOD1 1000003typedef unsigned long long int uint64;typedef long long int int64; int main(){ int t,n; cin>>t; while(t--){ cin>>n; int64 a=n; int64 b= n-2; if(a==1){ cout<<1<<endl; continue; } a=(a-b)*(a*a+b*b+a*b); cout<<a<<endl; } return 0;} Second solution #include<bits/stdc++.h>using namespace std;long long tests, q;__int128 cube(long long x){ __int128 res = x; res = res*res*res; return res;}int main(){ ios_base::sync_with_stdio(0); cin >> tests; for (; tests; --tests) { cin >> q; long long res; if (q == 1) res = cube(q) - cube(q - 1); else res = cube(q) - cube(q - 2); cout << res << endl; } return 0;} coding problems