mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
ff9985fa25
3700-3799
41 lines
672 B
C++
41 lines
672 B
C++
#include <string.h>
|
|
#include <stdio.h>
|
|
int s[1000005];
|
|
int bin(int x,int n)
|
|
{
|
|
int l,h,m;
|
|
l = 0;
|
|
h = n-1;
|
|
m = (l+h/2);
|
|
while(l<=h)
|
|
{
|
|
m = (l+h)/2;
|
|
if(x<s[m])
|
|
h = m-1;
|
|
else if(x>s[m])
|
|
l = m+1;
|
|
else
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
int main()
|
|
{
|
|
int n,m,i,j,a;
|
|
while(~scanf("%d%d",&n,&m),n+m)
|
|
{
|
|
for(i = 0;i<n;i++)
|
|
{
|
|
scanf("%d",&s[i]);
|
|
}
|
|
int cnt = 0;
|
|
for(i = 0;i<m;i++)
|
|
{
|
|
scanf("%d",&a);
|
|
cnt+=bin(a,n);
|
|
}
|
|
printf("%d\n",cnt);
|
|
}
|
|
return 0;
|
|
}
|