/** * 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 h[1501], w[1501]; int N, M; while (cin >> N >> M, (N || M)) { for (int i=0; i> t; h[i] = t; } for (int i=0; i> t; w[i] = t; } map V, H; for (int i=0; i::iterator it = V.begin(); it != V.end(); it++) { int key = it->first; count += V[key] * H[key]; } cout << count << endl; } return 0; }