#include #include using namespace std; const int MAXS = 1000; const int EMPTY = -1; int t[2][MAXS]; int n[2]; int s[2]; int hash(int val, int itab) { return val%s[itab]; } int main() { int m, icase=0;; cin >> s[0] >> s[1] >> m; while (s[0] != 0) { cout << "Case " << ++icase << ":" << endl; for(int i=0; i> val; int j = 0; int hval = hash(val, j); int count=0; while (t[j][hval] != EMPTY) { if (++count > s[0]+s[1]) { cout << "ERROR: need to rehash" << endl; exit(-1); } int tmp = t[j][hval]; t[j][hval] = val; val = tmp; j = 1-j; hval = hash(val, j); } t[j][hval] = val; n[j]++; } if (n[0] > 0) { cout << "Table 1" << endl; for(int i=0; i 0) { cout << "Table 2" << endl; for(int i=0; i> s[0] >> s[1] >> m; } }