TopCoder SRM 146 DIV 1 Easy 練習

問題

長方形の中に部分長方形がいくつとれますか。

全ての大きさの部分長方形について、数を全部足すだけ。

using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.Generic;

public class RectangularGrid {
    public long countRectangles(int width, int height) {
        long res = 0;
        for (int w = 1; w <= width; ++w)
            for (int h = 1; h <= height; ++h)
                if (w != h)
                    res += (width - w + 1) * (height - h + 1);
        return res;
    }
}