/** * Square Route (Problem D, Practice Contest for Japan Domestic, 2007-06-24) * by Kenji Inoue, 2007-06-28 **/ #include #include using namespace std; int main() { int y[1501], x[1501]; int N, M; while (cin >> N >> M, (N || M)) { y[0] = 0; for (int i=0; i> t; y[i+1] = y[i] + t; } x[0] = 0; for (int i=0; i> t; x[i+1] = x[i] + t; } map diag; for (int i=0; i::iterator it = diag.begin(); it != diag.end(); it++) { int v = it->second; count += v * (v-1) / 2; } cout << count << endl; } return 0; }