Description
hwf h w f 每天都会通过做题来签到,今天也不例外。
他上午做了 a a 道题,下午做了道题,但是 hwf h w f 记忆力不太好,刷一题,忘一题,所以有时候可能会刷重复的题,现在 hwf h w f 想知道自己一天一共刷了多少的题(同一题刷多次只算一次)。
Input
第一行有两个整数 a,b(0≤a,b≤100000) a , b ( 0 ≤ a , b ≤ 100000 ) 分别代表上午写的题目数量和下午写的题目数量。
第二行有 a a 个整数,第个数 ai a i 表示上午刷的题号 (1≤ai≤1000000) ( 1 ≤ a i ≤ 1000000 ) 。
第三行 b b 个数,第个数 bi b i 表示下午刷的题号 (1≤bi≤1000000) ( 1 ≤ b i ≤ 1000000 ) 。
Output
一个整数,表示他今天做了多少道题。
Sample Input
2 2
1 2
1 3
Sample Output
3
Solution
水题,开个标记数组标记下已经做过的题然后累加标记即可
Code
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f,maxn=1000005;
int n,m,a,vis[maxn],ans=0;
int main()
{
scanf("%d%d",&n,&m);
n+=m;
while(n--)
{
scanf("%d",&a);
vis[a]=1;
}
for(int i=1;i<=1000000;i++)ans+=vis[i];
printf("%d\n",ans);
return 0;
}