第二次写,考场上自己独立写出来了。但是sum没有用long long,丢了一个数据,很失败
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5+10;
int k;
char c1,c2;
string str;
int xx,yy;
int main()
{
// 请在此输入您的代码
cin>>k;
cin>>str>>c1>>c2;
long long sum=0;
for(int i=0,j=k-1;i<str.size()-k+1;i++,j++){
if(str[i] == c1) xx++;
if(str[j] == c2) sum+=xx;
}
cout<<sum<<endl;
return 0;
}