Created
January 7, 2014 16:19
-
-
Save danicat/8301797 to your computer and use it in GitHub Desktop.
TopCoder SRM 146 Division 2 500 pts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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