Don't like ads? PRO users don't see any ads ;-)
Guest

CD

By: a guest on Apr 26th, 2012  |  syntax: None  |  size: 0.78 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <cstdio>
  2. #include <cstring>
  3. #include <cstdlib>
  4. #include <cctype>
  5. #include <cmath>
  6. #include <algorithm>
  7. #include <iostream>
  8. #include <fstream>
  9.  
  10. using namespace std;
  11.  
  12. bool a[1000010];
  13.  
  14. int main ()
  15. {
  16.     long long n,m,i,j,temp,count;
  17.  
  18.     //freopen ("input.txt","r",stdin);
  19.     //freopen ("output.txt","w",stdout);
  20.  
  21.     memset (a,false,sizeof(a));
  22.  
  23.     while (scanf ("%lld%lld",&n,&m))
  24.     {
  25.         if (!n && !m)
  26.             break;
  27.  
  28.         for (i=0;i<n;i++)
  29.         {
  30.             scanf ("%lld",&temp);
  31.  
  32.             a[temp]=true;
  33.         }
  34.  
  35.         count=0;
  36.  
  37.         for (i=0;i<m;i++)
  38.         {
  39.             scanf("%lld",&temp);
  40.  
  41.             if (a[temp]==true)
  42.              count++;
  43.         }
  44.         printf ("%lld\n",count);
  45.     }
  46.     return 0;
  47. }