Header Ad

HackerEarth An equilateral triangle problem solution

In this HackerEarth An equilateral triangle problem solution The shape of a network is a big equilateral triangle and it consists of many small equilateral triangles of different sizes. Each point represents a computer and you have to choose a rectangle such that each of its corners is a computer and the horizontal edges are parallel with the lower edge of the network(big triangle) The size of the network is the number of small triangles on each edge of the big triangle. You need to count the number of rectangles that can be selected from the network.


HackerEarth An equilateral triangle problem solution


HackerEarth An equilateral triangle problem solution.

#include<bits/stdc++.h>
using namespace std;
int n,ans;
int32_t main()
{
cin>>n;
for(int i=1;i<n;i++)
ans+=(i+1)*i*((n-i)/2)/2;
cout<<ans<<endl;
return 0;
}


Post a Comment

0 Comments