Skip to content

Instantly share code, notes, and snippets.

@MasterAlish
Created August 22, 2013 19:03
Show Gist options
  • Save MasterAlish/6311379 to your computer and use it in GitHub Desktop.
Save MasterAlish/6311379 to your computer and use it in GitHub Desktop.
Solution for "sunloverz / gist:6309925" on c++
#include <stdio.h>
class RectangularGrid{
public:
long long countRectangles(int n, int m){
long long sum=0;
for(int i_n=1; i_n<=n; i_n++)
for(int i_m=1; i_m<=m; i_m++)
if(i_m!=i_n)
sum+=(m-i_m+1)*(n-i_n+1);
return sum;
};
};
int main(){
RectangularGrid* r = new RectangularGrid();
printf("%lld",r->countRectangles(3,3));
printf("%lld",r->countRectangles(2,5));
printf("%lld",r->countRectangles(592,964));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment