4fd800b3a8 2011-02-23 kinaba: using namespace std; 4fd800b3a8 2011-02-23 kinaba: 4fd800b3a8 2011-02-23 kinaba: struct RectangularGrid 4fd800b3a8 2011-02-23 kinaba: { 4fd800b3a8 2011-02-23 kinaba: long long countRectangles(int width, int height) 4fd800b3a8 2011-02-23 kinaba: { 4fd800b3a8 2011-02-23 kinaba: long long w = width+1; 4fd800b3a8 2011-02-23 kinaba: long long h = height+1; 4fd800b3a8 2011-02-23 kinaba: long long s = w*(w-1)/2*h*(h-1)/2; 4fd800b3a8 2011-02-23 kinaba: for(long long x=1; x<w && x<h; ++x) 4fd800b3a8 2011-02-23 kinaba: s -= (w-x)*(h-x); 4fd800b3a8 2011-02-23 kinaba: return s; 4fd800b3a8 2011-02-23 kinaba: } 4fd800b3a8 2011-02-23 kinaba: };