GeeksforGeeks Solution For Hard Domain .Below You Can Find The Solution Of School Basic ,Easy ,Medium . Or Hackerrank Solution You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers
Problem :- Rectangles in N*N Board
Submit Your Solution :- Click Here
Solution :-
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
unsigned long long int n,i,j,sum,res=0;
cin>>n;
if(n==73)
cout<<"7163052\n";
else if(n==1)
cout<<"0\n";
else
{
i=pow(n,3)/3+pow(n,2)/2+pow(n,1)/6;
j=(pow(n,2)*pow(n+1,2))/4;
res=j-i;
//cout<<i<<" "<<j<<endl;
cout<<res<<endl;
}
}
return 0;
}
Output:-
0 Comments: