| 非正经题解 | 统计acgo的出现次
2025-02-05 17:30:40
发布于:江苏
17阅读
0回复
0点赞
#include<iostream>
#include<string>
using namespace std;
const int MOD=998244353;
int f(const string& S) {
long long a=0,ac=0,acg=0,acgo=0;
for (char c:S){
if (c=='a'){
a=(a+1)%MOD;
}else if(c=='c'){
ac=(ac+a)%MOD;
}else if(c=='g'){
acg=(acg+ac)%MOD;
} else if (c=='o') {
acgo=(acgo+acg)%MOD;
}
}
return static_cast<int>(acgo);
}
int main() {
int N;
string S;
cin>>N>>S;
int result =f(S);
cout<<result<<endl;
return 0;
}
这里空空如也
有帮助,赞一个