Skip to content

Instantly share code, notes, and snippets.

@danicat
Created January 7, 2014 16:19
Show Gist options
  • Save danicat/8301797 to your computer and use it in GitHub Desktop.
Save danicat/8301797 to your computer and use it in GitHub Desktop.
TopCoder SRM 146 Division 2 500 pts.
class RectangularGrid {
public:
long long countRectangles(int width, int height) {
long long count = 0;
for(int w = 0; w < width; ++w) {
for(int h = 0; h < height; ++h) {
if( w == h ) continue;
count += (height-h) * (width-w);
}
}
return count;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment