AC代码(让数组a和数组b的长度相乘然后减去a中a和b想同的字母的个数注意用long long)
Select Code
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
freopen("concatenation.in", "r", stdin);
freopen("concatenation.out","w",stdout);
char a[100000+10], b[100000+10];
int n, m, i, sum[100000+10];
long long ans = 0;
cin>>a>>b;
n = strlen(a), m = strlen(b);
ans = (long long)n*(long long)m;
for(i = 1;i<n;i++)
{
sum[a[i]]++;
}
for(i = 0;i<m-1;i++)
{
ans-=sum[b[i]];
}
printf("%lld\n",ans);
return 0;
}