前缀和
#include<bits/stdc++.h>
#include<vector>
using namespace std;
typedef long long ll;
int k;
string s;
char c1,c2;
int main()
{
ios::sync_with_stdio(0);cin.tie(0);
cin>>k>>s>>c1>>c2;
int sum_c1 = 0;
int n = s.size();
ll ans = 0;
for(int i = k-1,j = 0;i<n;++j,++i)
{
if(s[j] == c1)
{
++sum_c1;
}
if(s[i]==c2)
{
ans += sum_c1;
}
}
cout<<ans<<endl;
return 0;
}
0 回复
0 转发
0 喜欢
1 阅读



