|
|
вернуться в форумWhy WA on test 32? Please! Give me 32 test Re: Why WA on test 32? Послано r1d1 6 дек 2011 17:10 give program Re: Why WA on test 32? #include <stdio.h> #include <stdlib.h> static int b_search(unsigned int array[], int n, int x); int main() { int i, k, nc; char u2f, u3f; unsigned int t; unsigned short n[3]; unsigned int u[3][4000]; for (i = 0; i < 3; i++){ scanf("%u", &(n[i])); for (k = 0; k < n[i]; k++){ scanf("%u", &t); u[i][k] = t; } } nc = 0; for (i = 0; i < n[0]; i++){ u2f = u3f = 0; if (i > n[1] || i > n[2]) break; u2f = b_search(u[1], n[1], u[0][i]) > -1; u3f = b_search(u[2], n[2], u[0][i]) > -1; if (u2f && u3f) nc++; } printf("%d\n", nc); return 0; } static int b_search(unsigned int array[], int n, int x) { int s, e, m; if (n == 0) return -1; s = 0; e = n; while (s < e){ m = (s+e)/2; if (x <= array[m]) e = m; else s = m + 1; } return array[e] == x ? e : -1; } Edited by author 06.12.2011 18:04 Edited by author 06.12.2011 18:20 |
|
|