/*************************************** * ************* Question: peter invited A friend to his party, but the invited person must meet the following requirements: at least A person who knows and B does not know each other at the party; calculate the maximum number of people invited by him. algorithm: This is a water question based on the data volume given by the question. That is, find an invalid node through cyclic search and delete its corresponding relationship; continue searching until every node is valid; **************************************** * ************/# include <iostream> # include <cstdio> # include <cmath> # include <cstring> using namespace std; const int n= 111; struct relation {int know, unknow;} a [N]; int map [N] [N]; bool Visit [N]; int n, m; int A, B; int solve () {int res = n; while (1) {int flag = 1; for (int I = 0; I <n; I ++) {if (! Visit [I] & (a [I]. know <A | a [I]. unknow <B) {visit [I] = 1; res --; flag = 0; for (int j = 0; j <n; j ++) {if (! Visit [j]) {if (map [I] [j]) {a [j]. know --;} else a [j]. unknow -- ;}}}if (flag) break; // All nodes meet the condition} return res;} int main () {// freopen ("C: \ Users \ Administrator \ Desktop \ kd.txt "," r ", stdin); int tcase = 1; while (~ Scanf ("% d", & n, & m, & A, & B) {if (! N &&! M &&! A &&! B) break; memset (a, 0, sizeof (a); memset (map, 0, sizeof (map); memset (visit, 0, sizeof (visit )); for (int I = 0; I <m; I ++) {int u, v; scanf ("% d", & u, & v ); map [u] [v] = map [v] [u] = 1; a [u]. know ++; a [v]. know ++ ;}for (int I = 0; I <n; I ++) {a [I]. unknow = n-a [I]. know-1; // number of people not recognized = n-recognized and himself} printf ("Case # % d: % d \ n", tcase ++, solve ();} return 0 ;}