lanqiao3514 字串简写
This commit is contained in:
21
14lanqiao/test7-2.cpp
Normal file
21
14lanqiao/test7-2.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
// lanqiao3514 字串简写(前缀和优化)
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
#define int long long
|
||||
signed main(){
|
||||
int k;
|
||||
string s;
|
||||
char a, b;
|
||||
cin >> k >> s >> a >> b;
|
||||
int ft = 0;
|
||||
int bk = 0;
|
||||
for(int i = 0, j = k - 1; j < s.size(); i++, j++){
|
||||
if(s[i] == a) ft++;
|
||||
if(s[j] == b) bk += ft;
|
||||
}
|
||||
cout << bk << endl;
|
||||
}
|
||||
/* samples -> 6
|
||||
4
|
||||
abababdb a b
|
||||
*/
|
||||
Reference in New Issue
Block a user