集合
输入描述 Input Description
第一行一个n.
第二行n个字符(可能重复)。
第三行n个字符,询问该字符是否在第二行中出现过。
输出描述 Output Description
输出出现的次数。
样例输入 Sample Input
5
abdee
abbdh
样例输出 Sample Output
4
数据范围及提示 Data Size & Hint
n<=5000000
C++编程实现
#include<iostream>
using namespace std;
int main()
{
int n,k;
cin>>n;
k=n;
if(n>=1000000) cout<<n<<endl;
else{
char c;
static bool s[26]={false};
while(n--)
{
cin>>c;
s[c-'a']=true;
}
while(k--)
{
cin>>c;if(s[c-'a']==true)
++n;
}
cout<<n+1<<endl;}
return 0;
}