Computer Programming Contest Preparation

ToolBox - Source for: 118/11849/a.cpp



/home/toolbox/public_html/solutions/118/11849/a.cpp
    1 #include <iostream>
    2 #include <cstdio>
    3 #include <algorithm>
    4 #include <cstring>
    5 #include <string>
    6 #include <cctype>
    7 #include <stack>
    8 #include <queue>
    9 #include <list>
   10 #include <vector>
   11 #include <map>
   12 #include <sstream>
   13 #include <cmath>
   14 #include <bitset>
   15 #include <utility>
   16 #include <set>
   17 #include <numeric>
   18 #include <ctime>
   19 
   20 /*
   21  *  Author: Isaac Traxler
   22  *    Date: 2018-08-28
   23  * Purpose: fun
   24  * Problem: 11849
   25  */
   26 
   27 using namespace std;
   28 
   29 int jackCnt;
   30 int jillCnt;
   31 
   32 int getInput()
   33 {
   34     /* FUNCTION getInput */
   35     int dataReadFlag;
   36 
   37     scanf(" %d %d ", &jackCnt, &jillCnt);
   38     dataReadFlag = ((0 != jackCnt) || (0 != jillCnt));
   39     return (dataReadFlag);
   40 } /* FUNCTION getInput */
   41 
   42 void process()
   43 {
   44     /* FUNCTION process */
   45     map<int,int> catalog;
   46     int i;
   47     int cnt = 0;
   48     int num;
   49 
   50     for (i=0; jackCnt>i; i++)
   51         {
   52             /* do all of Jack's CDs */
   53             scanf(" %d ", &num);
   54             catalog[num] = 1;
   55         } /* do all of Jack's CDs */
   56 
   57     for (i=0; jillCnt>i; i++)
   58         {
   59             /* do all of Jill's CDs */
   60             scanf(" %d ", &num);
   61             if (catalog.count(num))
   62                 {
   63                     cnt++;
   64                 }
   65         } /* do all of Jill's CDs */
   66 
   67     printf("%d\n", cnt);
   68 } /* FUNCTION process */
   69 
   70 int main()
   71 {
   72     /* main */
   73     int moreToDo;
   74 
   75     moreToDo = getInput();
   76     while (moreToDo)
   77         {
   78             /* while */
   79             process();
   80             moreToDo = getInput();
   81         } /* while */
   82 
   83     return EXIT_SUCCESS;
   84 
   85     return 0;
   86 } /* main */
   87 
   88