题意是求有多少个集合符合以下两种要求:
strictly increasing sequences p1,p2,…,pk such that:
- For each i (1≤i≤k), Spi=Spi= 'a'.
- For each i (1≤i<k), there is such j that pi<j<pi+1 and Sj= 'b'.
题意挺容易看错的。
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll mod = 1e9 + 7;
ll n,sum;
char s[100010];
int a[100010];
int main(){
cin>>s;
int n = strlen(s);
int count = 0;
sum = 0;
int p = 0;
for(int i = 0 ; i < n ; i++){
if(s[i]=='a'){
count++;
}else if(s[i]=='b'&&count!=0){
a[p++] = count;
count = 0;
}
}
if(count){
a[p++] = count;
}
sum = a[0]+1;
for(int i = 1 ;i < p ; i++){
sum*=a[i]+1;
sum%=mod;
}
cout<<sum-1<<endl;
}
//abaaba
//abaabaaabaa
//ababbaab