UVA Solution 11849 CD

Solve in C++:


#include<bits/stdc++.h>
using namespace std;
main()
{
    long n,m;
    while(cin>>n>>m)
    {
        long i,a,cnt=0;
        map<long,long>mp;
        if(n==0&&m==0)
            break;
        for(i=1;i<=n;i++)
        {
            cin>>a;
            mp[a]=1;
        }
        for(i=1;i<=m;i++)
        {
            cin>>a;
            if(mp[a]==1)
                cnt++;
        }
        cout<<cnt<<endl;
    }
}

No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h ...

Powered by Blogger.