题目大意
求出a字符串前缀与b字符串后缀组成的方案数
思路
a中出现过同时b中也出现为重复方案,总方案减去这些即可,(注意a.size()返回的是int型 需要手动转longlong)
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize("Ofast", "inline", "-ffast-math")
//#pragma GCC target("abm,avx,mmx,popcnt,sse,sse2,sse3,ssse3,sse4")
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#define int long long
#define dbg(x) cout << #x << '=' << x << endl
#define dbg1(x, y) cout << #x << '=' << x << ',' << #y << '=' << y << endl
#define FA ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define INF 0x3f3f3f3f
using namespace std;
const int N = 2e5 + 10, M = 2 * N, mod = 1e9 + 7;
const double eps = 1e-8;
typedef long long LL;
typedef pair<int, int> PII;
int n, m;
map<char, int> mp1, mp2;
void solve() {
string a, b;
cin >> a >> b;
for (int i = 1; i < a.size(); i++) {
mp1[a[i]]++;
}
for (int i = 0; i < b.size() - 1; i++) {
mp2[b[i]]++;
}
int ans = (int)a.size() * (int)b.size();
for (int i = 'a'; i <= 'z'; i++) {
ans -= mp1[i] * mp2[i];
}
cout << ans;
}
signed main() {
freopen("concatenation.in", "r", stdin);
freopen("concatenation.out", "w", stdout);
int T = 1; // cin>>T;
while (T--) solve();
}